Example #1
0
    public override void OnInspectorGUI()
    {
        GUILayout.Space(6f);
        EditorGUIUtility.labelWidth = 120f;

        MyTweenPosition tw = target as MyTweenPosition;

        GUI.changed = false;

        Vector3 from = EditorGUILayout.Vector3Field("From", tw.from);
        Vector3 to   = EditorGUILayout.Vector3Field("To", tw.to);

        bool worldSpace = EditorGUILayout.Toggle("WorldSpace", tw.worldSpace);

        if (GUI.changed)
        {
            MyEditorTool.RegisterUndo("Tween Change", tw);
            tw.from       = from;
            tw.to         = to;
            tw.worldSpace = worldSpace;
            MyEditorTool.SetDirty(tw);
        }

        DrawCommonProperties();
    }
    void OnEnable()
    {
        if (usePosition && fromPosition != toPosition)
        {
            MyTweenPosition tweenPos = this.gameObject.GetComponent <MyTweenPosition>();
            if (tweenPos == null)
            {
                tweenPos = this.gameObject.AddComponent <MyTweenPosition>();
            }
            tweenPos.worldSpace = worldSpace;
            tweenPos.style      = usePositionType;
            tweenPos.from       = fromPosition + transform.localPosition;
            tweenPos.to         = toPosition + transform.localPosition;
            tweenPos.duration   = timeOfPositionOnce;
            tweenPos.curve      = animationCurve_Position;
            tweenPos.ResetToBeginning();
            tweenPos.PlayForward();
        }
        else
        {
        }

        if (useScale && fromScale != toScale)
        {
            MyTweenScale tweenScal = this.gameObject.GetComponent <MyTweenScale>();
            if (tweenScal == null)
            {
                tweenScal = this.gameObject.AddComponent <MyTweenScale>();
            }
            tweenScal.style    = useScaleType;
            tweenScal.from     = fromScale;
            tweenScal.to       = toScale;
            tweenScal.duration = timeOfScaleOnce;
            tweenScal.curve    = animationCurve_Scale;
            tweenScal.ResetToBeginning();
            tweenScal.PlayForward();
        }
        else
        {
        }

        if (useRotat && fromAngle != toAngle)
        {
            MyTweenRotation tweenRotat = this.gameObject.GetComponent <MyTweenRotation>();
            if (tweenRotat == null)
            {
                tweenRotat = this.gameObject.AddComponent <MyTweenRotation>();
            }
            tweenRotat.style    = useRotatType;
            tweenRotat.from     = fromAngle;
            tweenRotat.to       = toAngle;
            tweenRotat.duration = timeOfRotatOnce;
            tweenRotat.curve    = animationCurve_Rotation;
            tweenRotat.ResetToBeginning();
            tweenRotat.PlayForward();
        }
        else
        {
        }

        if (useColor && fromColor != toColor)
        {
            MyTweenColor tweenColor = this.gameObject.GetComponent <MyTweenColor>();
            if (tweenColor == null)
            {
                tweenColor = this.gameObject.AddComponent <MyTweenColor>();
            }
            tweenColor.renderType      = type;
            tweenColor.shaderColorName = shaderColorName;
            tweenColor.style           = useColorType;
            tweenColor.from            = fromColor;
            tweenColor.to       = toColor;
            tweenColor.duration = timeOfColorOnce;
            tweenColor.curve    = animationCurve_Color;
            tweenColor.ResetToBeginning();
            tweenColor.PlayForward();
        }
        else
        {
        }
    }