• 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();
        }
  • 相关阅读:
    spark调度器FIFO,FAIR
    elasticsearch5.6.8 创建TransportClient工具类
    elasticsearch TransportClient bulk批量提交数据
    java 参数来带回方法运算结果
    idea上传代码到git本地仓库
    2020-03-01 助教一周小结(第三周)
    2020-02-23 助教一周小结(第二周)
    2020-02-16 助教一周小结(第一周)
    寻找两个有序数组的中位数
    无重复字符的最长子串
  • 原文地址:https://www.cnblogs.com/CodeSnippet/p/7412713.html
Copyright © 2020-2023  润新知