public override void OnInspectorGUI() { GUILayout.Space(6f); EditorGUIUtility.labelWidth = 120f; MyTweenColor tw = target as MyTweenColor; GUI.changed = false; Color from = EditorGUILayout.ColorField("From", tw.from); Color to = EditorGUILayout.ColorField("To", tw.to); RenderType renderType = (RenderType)EditorGUILayout.EnumPopup("RenderType", tw.renderType); if (renderType == RenderType.ShaderColor) { tw.shaderColorName = EditorGUILayout.TextField("RenderType", tw.shaderColorName); } if (GUI.changed) { MyEditorTool.RegisterUndo("Tween Change", tw); tw.from = from; tw.to = to; tw.renderType = renderType; 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 { } }