插件地址:https://www.assetstore.unity3d.com/cn/#!/content/69779
SequencialCompositeAction:按顺序执行Action。
例子:
UnityActions.Init();IAction action = new SequencialCompositeAction( new Delay(TimeSpan.FromSeconds(2)), new DelegateAction(() => "Over".DebugLog()) );action.Execute();
ConcurrentCompositeAction:并行执行Action。
例子:
UnityActions.Init(); IAction action = new ConcurrentCompositeAction( new Delay(TimeSpan.FromSeconds(2)), new DelegateAction(() => "Over".DebugLog()) ); action.Execute();
PredicateBasedDualAction:判断执行Action。(if else)
例子:
UnityActions.Init(); IAction action = new PredicateBasedDualAction( () => true, new DelegateAction(() => "True".DebugLog()), new DelegateAction(() => "False".DebugLog()) ); action.Execute();
PredicateBasedDecorator:判断是否执行Action。(if)
例子:
UnityActions.Init(); IAction action = new PredicateBasedDecorator( new DelegateAction(() => "True".DebugLog()), () => true ); action.Execute();
ExceptionBasedDualAction<T>:当第一个Action捕获异常,将会执行第二个Action。
例子:
UnityActions.Init(); IAction action = new ExceptionBasedDualAction( new DelegateAction(() => myName.DebugLog()), new DelegateAction(() => "your name is null".DebugLog()) ); action.Execute();
TriggeredAction:当条件满足则触发Action并往下继续执行,否则停滞。
例子:
public bool condition;//在编辑器中手动赋值即可看到触发效果。 private void Start() { UnityActions.Init(); IAction action = new SequencialCompositeAction( new TriggeredAction( new AnonymousTrigger(() => condition),//自定义条件需要使用该类 new DelegateAction(() => "Triggered".DebugLog()) ) ); action.Execute(); }