zoukankan      html  css  js  c++  java
  • Unity插件学习记录 -- SW Actions

    插件地址: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<ArgumentNullException>(
                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();
        }
  • 相关阅读:
    Math对象
    MDN中的对象原型
    构造函数的静态成员和实例成员
    js对象的九大特点
    对象数据的使用方法
    创建对象的所有方式
    Linux下gcc编译器的使用
    Linux vim环境设置
    Linux下is not in the sudoers file解决方法
    mySQL相关函数的使用
  • 原文地址:https://www.cnblogs.com/CodeSnippet/p/7412713.html
Copyright © 2011-2022 走看看