Ejemplo n.º 1
0
        public static TweenOperation Composite(TweenOperation p1, TweenOperation p2)
        {
            var operations = ListPool <TweenOperation> .Request();

            operations.Add(p1);
            operations.Add(p2);
            return(CompositeInternal(operations));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 将TweenOperation与目标gameObject的生命周期进行绑定, 通过BehaviourBindSetting设置在不同的回调函数执行不同的行为。
        /// <para>注意: 当一个go首次被绑定时,会有创建MonoBehaviour的开销。所以不宜大量频繁的往不同的gameObject进行Bind操作。</para>
        /// <para>通常来说,一个比较好的方式是:在一个Scene场景创建一个通用的gameObject作为绑定目标,来处理这个场景里所有动画。例如,场景关闭时,暂停所有Tween动画,场景销毁时,销毁所有动画</para>
        /// </summary>
        public static TweenOperation Bind(this TweenOperation operation, GameObject go, BehaviourBindSetting setting)
        {
            var b = go.GetComponent <TweenBehaviourBinding>();

            if (!b)
            {
                b = go.AddComponent <TweenBehaviourBinding>();
            }
            b.Bind(operation, setting);
            return(operation);
        }
Ejemplo n.º 3
0
        public static TweenOperation Create(TweenOperation source, int repeatCount)
        {
            source.autoRelease = false;
            source.paused      = true;
            var state = new State()
            {
                source      = source,
                repeatCount = repeatCount
            };

            return(TweenAction <State> .Prepare(state, new TweenOptions(repeatCount *source.duration)));
        }
Ejemplo n.º 4
0
        public static TweenOperation Create(TweenOperation source)
        {
            if (source.duration <= 0)
            {
                throw new System.ArgumentException("The duration of the tween must be positive.");
            }
            source.autoRelease = false;
            source.paused      = true;
            var state = new State()
            {
                operation = source
            };

            return(TweenAction <State> .Prepare(state, new TweenOptions(float.MaxValue)));
        }
Ejemplo n.º 5
0
 public static TweenOperation Bind(this TweenOperation operation, GameObject go)
 {
     return(Bind(operation, go, BehaviourBindSetting.Default));
 }
Ejemplo n.º 6
0
        public void Bind(TweenOperation operation, BehaviourBindSetting setting)
        {
            RemoveAllCompletedOperations();
            if (setting.behaviourOnEnable != BehaviourType.None)
            {
                var item = new OperationItem()
                {
                    behaviour = setting.behaviourOnEnable,
                    operation = operation
                };
                if (_processingEnable)
                {
                    AddItemToList(ref item, _enableBehaviours);
                }
                else
                {
                    var completed = false;
                    if (this.isActiveAndEnabled)
                    {
                        //if current is enabled, do behaviour immediately
                        completed = ProcessOperationItem(ref item);
                    }
                    if (!completed)
                    {
                        AddItemToList(ref item, _enableBehaviours);
                    }
                }
            }

            if (setting.behaviourOnDisable != BehaviourType.None)
            {
                var item = new OperationItem()
                {
                    behaviour = setting.behaviourOnDisable,
                    operation = operation
                };
                if (_processingDisable)
                {
                    AddItemToList(ref item, _disableBehaviours);
                }
                else
                {
                    var completed = false;
                    if (!this.isActiveAndEnabled)
                    {
                        //if current is disabled, do behaviour immediately.
                        completed = ProcessOperationItem(ref item);
                    }
                    if (!completed)
                    {
                        AddItemToList(ref item, _disableBehaviours);
                    }
                }
            }

            if (setting.behaviourOnDestroy != BehaviourType.None)
            {
                var item = new OperationItem()
                {
                    behaviour = setting.behaviourOnDestroy,
                    operation = operation
                };
                if (this == null)
                {
                    //already destroyed
                    ProcessOperationItem(ref item);
                }
                else
                {
                    AddItemToList(ref item, _destroyBehaviours);
                }
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Repeat the tween forever
 /// </summary>
 public static TweenOperation RepeatForever(TweenOperation operation)
 {
     return(TweenRepeatForever.Create(operation));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Repeat the tween in specific times.
 /// </summary>
 public static TweenOperation Repeat(TweenOperation operation, int repeatCount)
 {
     return(TweenRepeat.Create(operation, repeatCount));
 }
Ejemplo n.º 9
0
 public static TweenOperation Parallel(TweenOperation p1, TweenOperation p2, TweenOperation p3, TweenOperation p4)
 {
     return(TweenParallel.Composite(p1, p2, p3, p4));
 }
Ejemplo n.º 10
0
 public static TweenOperation Sequence(TweenOperation p1, TweenOperation p2, TweenOperation p3, TweenOperation p4)
 {
     return(TweenSequence.Composite(p1, p2, p3, p4));
 }