示例#1
0
        private void DrawMovementMethodProperties()
        {
            // Draw movement type enum if any of the selected objects are set to animatie movement.
            bool drawMovementTypeEnum             = false;
            List <MovementMethod> movementMethods = new List <MovementMethod>();
            List <float>          sinScales       = new List <float>();

            foreach (var obj in serializedObject.targetObjects)
            {
                var tweenable = (Tweenable)obj;
                if (tweenable.AnimateTransform)
                {
                    drawMovementTypeEnum = true;
                    if (!movementMethods.Contains(tweenable.MovementMethod))
                    {
                        movementMethods.Add(tweenable.MovementMethod);
                    }
                    if (!sinScales.Contains(tweenable.SinusodalScale))
                    {
                        sinScales.Add(tweenable.SinusodalScale);
                    }
                }
            }

            if (!drawMovementTypeEnum)
            {
                return;
            }

            // Draw movement method selector.
            MovementMethod newMethod;
            bool           movementTypeChanged = DrawPossiblyMixedEnumProperty("Movement method", movementMethods, out newMethod);

            // Draw sinusodal scale selector if applicable.
            float newSinScale     = 0;
            bool  sinScaleChanged = false;

            if (newMethod == MovementMethod.Sinusodal)
            {
                sinScaleChanged = DrawPossiblyMixedFloatProperty("Sinusodal scale", sinScales, out newSinScale);
            }

            foreach (var obj in serializedObject.targetObjects)
            {
                // Apply values.
                Tweenable tweenable     = (Tweenable)obj;
                var       serializedObj = new SerializedObject(tweenable.gameObject);
                if (movementTypeChanged)
                {
                    tweenable.MovementMethod = newMethod;
                }
                if (sinScaleChanged)
                {
                    tweenable.SinusodalScale = newSinScale;
                }

                serializedObj.ApplyModifiedProperties();
            }
        }
示例#2
0
        private IEnumerator RunTweenWithDelay(Tweenable tweenable, bool toIn, float delay)
        {
            if (tweenable.DelayMode == DelayModes.Both || tweenable.DelayMode == DelayModes.InOnly && toIn || tweenable.DelayMode == DelayModes.OutOnly && !toIn)
            {
                yield return(new WaitForSecondsRealtime(delay));
            }

            tweenable.TweenToState(toIn);
        }
        void OnEnable()
        {
            _tweenable  = GetComponent <Tweenable>();
            _inStateSet = true;

            if (TargetLayoutElement == null)
            {
                TargetLayoutElement = GetComponent <LayoutElement>();
            }
        }