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();
        }
  • 相关阅读:
    11、python+selenium绕过验证码登录
    12、js处理web页面滚动条
    5、Frame和iframe框架定位
    2、常用的8种元素定位方法
    1、selenium环境搭建与浏览器基本操作
    python之logging模块
    Python数据驱动工具——DDT
    python利用session保持登录状态
    python利用Excel读取和存储测试数据完成接口自动化
    python利用openpyxl库操作Excel来读取、修改、写入测试数据
  • 原文地址:https://www.cnblogs.com/CodeSnippet/p/7412713.html
Copyright © 2011-2022 走看看