public override void OnEnable() { base.OnEnable(); tweenAction = (PlayMaker.Actions.TweenScale)target; }
public override void OnSceneGUI() { if (Application.isPlaying) { return; } tweenAction = target as PlayMaker.Actions.TweenScale; if (tweenAction == null) // shouldn't happen! { return; } // setup start and end positions var go = ActionHelpers.GetOwnerDefault(tweenAction, tweenAction.gameObject); if (go == null) { return; } // handles var transform = go.transform; var position = transform.position; var handleSize = HandleUtility.GetHandleSize(position); var showFromHandles = false; switch (tweenAction.fromOptions) { case ScaleOptions.CurrentScale: break; case ScaleOptions.LocalScale: if (tweenAction.fromScale.IsNone) { break; } tempScale.Set(tweenAction.fromScale.Value.x / transform.localScale.x, tweenAction.fromScale.Value.y / transform.localScale.y, tweenAction.fromScale.Value.z / transform.localScale.z); ActionHelpers.DrawWireBounds(transform, tempScale, PlayMakerPrefs.TweenFromColor); showFromHandles = true; break; case ScaleOptions.MultiplyScale: if (tweenAction.fromScale.IsNone) { break; } ActionHelpers.DrawWireBounds(transform, tweenAction.fromScale.Value, PlayMakerPrefs.TweenFromColor); showFromHandles = true; break; case ScaleOptions.AddToScale: if (tweenAction.fromScale.IsNone) { break; } tempScale.Set((tweenAction.fromScale.Value.x + transform.localScale.x) / transform.localScale.x, (tweenAction.fromScale.Value.y + transform.localScale.y) / transform.localScale.y, (tweenAction.fromScale.Value.z + transform.localScale.z) / transform.localScale.z); ActionHelpers.DrawWireBounds(transform, tempScale, PlayMakerPrefs.TweenFromColor); showFromHandles = true; break; case ScaleOptions.MatchGameObject: var fromGo = tweenAction.fromTarget.Value; if (fromGo == null) { break; } ActionHelpers.DrawWireBounds(transform, fromGo.transform.localScale, PlayMakerPrefs.TweenFromColor); showFromHandles = true; break; /* * case ScaleOptions.MatchGameObjectMultiply: * var fromGo = tweenAction.fromTarget.Value; * if (fromGo == null) break; * var matchScale = fromGo.transform.localScale; * tempScale.Set(tweenAction.fromScale.Value.x * matchScale.x / transform.localScale.x, * tweenAction.fromScale.Value.y * matchScale.y / transform.localScale.y, * tweenAction.fromScale.Value.z * matchScale.z / transform.localScale.z); * ActionHelpers.DrawWireBounds(transform, tempScale, PlayMakerPrefs.TweenFromColor); * showFromHandles = true; * break;*/ default: throw new ArgumentOutOfRangeException(); } if (showFromHandles) { tweenAction.fromScale.Value = ActionHelpers.SingleColorScaleHandle(go, tweenAction.fromScale.Value, handleSize * 1.4f, PlayMakerPrefs.TweenFromColor); } var showToHandles = false; switch (tweenAction.toOptions) { case ScaleOptions.CurrentScale: break; case ScaleOptions.LocalScale: if (tweenAction.toScale.IsNone) { break; } tempScale.Set(tweenAction.toScale.Value.x / transform.localScale.x, tweenAction.toScale.Value.y / transform.localScale.y, tweenAction.toScale.Value.z / transform.localScale.z); ActionHelpers.DrawWireBounds(transform, tempScale, PlayMakerPrefs.TweenToColor); showToHandles = true; break; case ScaleOptions.MultiplyScale: if (tweenAction.toScale.IsNone) { break; } ActionHelpers.DrawWireBounds(transform, tweenAction.toScale.Value, PlayMakerPrefs.TweenToColor); showToHandles = true; break; case ScaleOptions.AddToScale: if (tweenAction.toScale.IsNone) { break; } tempScale.Set((tweenAction.toScale.Value.x + transform.localScale.x) / transform.localScale.x, (tweenAction.toScale.Value.y + transform.localScale.y) / transform.localScale.y, (tweenAction.toScale.Value.z + transform.localScale.z) / transform.localScale.z); ActionHelpers.DrawWireBounds(transform, tempScale, PlayMakerPrefs.TweenToColor); showToHandles = true; break; case ScaleOptions.MatchGameObject: var toGo = tweenAction.toTarget.Value; if (toGo == null) { break; } var matchScale = toGo.transform.localScale; tempScale.Set(tweenAction.toScale.Value.x * matchScale.x / transform.localScale.x, tweenAction.toScale.Value.y * matchScale.y / transform.localScale.y, tweenAction.toScale.Value.z * matchScale.z / transform.localScale.z); ActionHelpers.DrawWireBounds(transform, tempScale, PlayMakerPrefs.TweenToColor); showToHandles = true; break; default: throw new ArgumentOutOfRangeException(); } if (showToHandles) { tweenAction.toScale.Value = ActionHelpers.SingleColorScaleHandle(go, tweenAction.toScale.Value, handleSize * 1.8f, PlayMakerPrefs.TweenToColor); } if (GUI.changed) { FsmEditor.SaveActions(); } }