public override void init(GoTween owner)
        {
            // setup our target before initting
            if (owner.target is Material)
            {
                _target = (Material)owner.target;
            }
            else if (owner.target is GameObject)
            {
                _target = ((GameObject)owner.target).GetComponent <Renderer>().material;
            }
            else if (owner.target is Transform)
            {
                _target = ((Transform)owner.target).GetComponent <Renderer>().material;
            }
            else if (owner.target is Renderer)
            {
                _target = ((Renderer)owner.target).material;
            }

            base.init(owner);
        }
Пример #2
0
        /// <summary>
        /// checks for duplicate properties. if one is found and the DuplicatePropertyRuleType is set to
        /// DontAddCurrentProperty it will return true indicating that the tween should not be added.
        /// this only checks tweens that are not part of an AbstractTweenCollection
        /// </summary>
        private static bool handleDuplicatePropertiesInTween(GoTween tween)
        {
            // first fetch all the current tweens with the same target object as this one
            var allTweensWithTarget = tweensWithTarget(tween.target);

            // store a list of all the properties in the tween
            var allProperties = tween.allTweenProperties();

            // TODO: perhaps only perform the check on running Tweens?

            // loop through all the tweens with the same target
            foreach (var tweenWithTarget in allTweensWithTarget)
            {
                // loop through all the properties in the tween and see if there are any dupes
                foreach (var tweenProp in allProperties)
                {
                    warn("found duplicate TweenProperty {0} in tween {1}", tweenProp, tween);

                    // check for a matched property
                    if (tweenWithTarget.containsTweenProperty(tweenProp))
                    {
                        // handle the different duplicate property rules
                        if (duplicatePropertyRule == GoDuplicatePropertyRuleType.DontAddCurrentProperty)
                        {
                            return(true);
                        }
                        else if (duplicatePropertyRule == GoDuplicatePropertyRuleType.RemoveRunningProperty)
                        {
                            // TODO: perhaps check if the Tween has any properties left and remove it if it doesnt?
                            tweenWithTarget.removeTweenProperty(tweenProp);
                        }

                        return(false);
                    }
                }
            }

            return(false);
        }