public override void OnSceneGUI()
        {
            if (Application.isPlaying)
            {
                return;
            }

            // setup start and end positions

            var go = ActionHelpers.GetOwnerDefault(tweenAction, tweenAction.gameObject);

            if (go == null)
            {
                return;
            }

            var transform = go.transform;
            var startPos  = new Vector3();
            var endPos    = new Vector3();

            if (!TweenHelpers.GetTargetPosition(tweenAction.fromOption, transform,
                                                tweenAction.fromPosition, tweenAction.fromTarget, out startPos))
            {
                return;
            }

            if (!TweenHelpers.GetTargetPosition(tweenAction.toOption, transform,
                                                tweenAction.toPosition, tweenAction.toTarget, out endPos))
            {
                return;
            }

            EditorGUI.BeginChangeCheck();

            if (TweenHelpers.CanEditTargetPosition(tweenAction.fromOption, tweenAction.fromPosition, tweenAction.fromTarget))
            {
                tweenAction.fromPosition.Value = TweenHelpers.DoTargetPositionHandle(startPos, tweenAction.fromOption,
                                                                                     transform, tweenAction.fromTarget);
            }

            if (TweenHelpers.CanEditTargetPosition(tweenAction.toOption, tweenAction.toPosition, tweenAction.toTarget))
            {
                tweenAction.toPosition.Value = TweenHelpers.DoTargetPositionHandle(endPos, tweenAction.toOption,
                                                                                   transform, tweenAction.toTarget);
            }

            var rotation = transform.rotation;

            ActionHelpers.DrawWireBounds(transform, startPos, rotation, PlayMakerPrefs.TweenFromColor);
            ActionHelpers.DrawWireBounds(transform, endPos, rotation, PlayMakerPrefs.TweenToColor);
            ActionHelpers.DrawArrow(startPos, endPos, PlayMakerPrefs.TweenToColor);

            if (EditorGUI.EndChangeCheck())
            {
                FsmEditor.SaveActions();
            }
        }
示例#2
0
        /// <summary>
        /// Reset scale parameter with sensible default value when changing options
        /// </summary>
        private void ResetSharedParameter(ref FsmVector3 scale)
        {
            if (scale.UsesVariable)
            {
                return;                     // don't reset variable value!
            }
            switch (tweenAction.toOptions)
            {
            case ScaleOptions.LocalScale:
                var go = ActionHelpers.GetOwnerDefault(tweenAction, tweenAction.gameObject);
                scale.Value = go != null ? go.transform.localScale : Vector3.one;
                break;

            case ScaleOptions.MultiplyScale:
                scale.Value = Vector3.one;
                break;

            case ScaleOptions.AddToScale:
                scale.Value = Vector3.zero;
                break;
            }
        }
示例#3
0
        public override void OnSceneGUI()
        {
            if (Application.isPlaying)
            {
                return;
            }

            tweenAction = target as PlayMaker.Actions.TweenRotation;
            if (tweenAction == null) // shouldn't happen!
            {
                return;
            }

            // setup start and end positions

            var go = ActionHelpers.GetOwnerDefault(tweenAction, tweenAction.gameObject);

            if (go == null)
            {
                return;
            }

            // setup handles

            var transform = go.transform;
            //var position = transform.position;
            //var rotation = transform.rotation;
            //var handleSize = HandleUtility.GetHandleSize(position);

            var startRotation = Quaternion.identity;

            if (PlayMaker.Actions.TweenHelpers.GetTargetRotation(tweenAction.fromOptions, transform,
                                                                 tweenAction.fromRotation, tweenAction.fromTarget, out startRotation))
            {
                ActionHelpers.DrawWireBounds(transform, startRotation, PlayMakerPrefs.TweenFromColor);
            }

            var endRotation = Quaternion.identity;

            if (PlayMaker.Actions.TweenHelpers.GetTargetRotation(tweenAction.toOptions, transform,
                                                                 tweenAction.toRotation, tweenAction.toTarget, out endRotation))
            {
                ActionHelpers.DrawWireBounds(transform, endRotation, PlayMakerPrefs.TweenToColor);
            }

            /*
             * Transform fromTransform = null;
             * if (tweenAction.fromTarget != null)
             * {
             *  fromTransform = tweenAction.fromTarget.Value != null ? tweenAction.fromTarget.Value.transform : null;
             * }
             *
             * Transform toTransform = null;
             * if (tweenAction.toTarget != null)
             * {
             *  toTransform = tweenAction.toTarget.Value != null ? tweenAction.toTarget.Value.transform : null;
             * }
             *
             * var startRotation = ActionHelpers.GetTargetRotation(tweenAction.fromOptions, transform, fromTransform, tweenAction.fromRotation.Value);
             * var endRotation = ActionHelpers.GetTargetRotation(tweenAction.toOptions, transform, toTransform, tweenAction.toRotation.Value);
             *
             * var showFromHandles = ActionHelpers.CanEditTargetRotation(tweenAction.fromOptions, tweenAction.fromRotation, tweenAction.fromTarget);
             * if (showFromHandles)
             * {
             *  ActionHelpers.DrawWireBounds(transform, startRotation, PlayMakerPrefs.TweenFromColor);
             *  // Need a custom control for this?
             *  // tweenAction.fromRotation.Value = Handles.RotationHandle(tweenAction.fromRotation.Value, transform.position);
             * }
             *
             * var showToHandles = ActionHelpers.CanEditTargetRotation(tweenAction.toOptions, tweenAction.toRotation, tweenAction.toTarget);
             * if (showToHandles)
             * {
             *  ActionHelpers.DrawWireBounds(transform, endRotation, PlayMakerPrefs.TweenToColor);
             *  // Need a custom control for this?
             *  // tweenAction.fromRotation.Value = Handles.RotationHandle(tweenAction.fromRotation.Value, transform.position);
             * }*/

            if (GUI.changed)
            {
                FsmEditor.SaveActions();
            }
        }
示例#4
0
        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();
            }
        }