Esempio n. 1
0
        public override bool OnGUI()
        {
            EditorGUI.BeginChangeCheck();

            EditField("gameObject");

            EditorGUI.BeginChangeCheck();
            EditField("fromOptions");
            if (EditorGUI.EndChangeCheck())
            {
                tweenAction.fromTarget.Value   = null;
                tweenAction.fromRotation.Value = Vector3.zero;
                FsmEditor.SaveActions();
            }

            DoOptionUI(tweenAction.fromOptions, "fromRotation", "fromTarget");

            EditorGUI.BeginChangeCheck();
            EditField("toOptions");
            if (EditorGUI.EndChangeCheck())
            {
                tweenAction.toTarget.Value   = null;
                tweenAction.toRotation.Value = Vector3.zero;
                FsmEditor.SaveActions();
            }

            DoOptionUI(tweenAction.toOptions, "toRotation", "toTarget");

            DoEasingUI();

            return(EditorGUI.EndChangeCheck());
        }
Esempio n. 2
0
        private void SelectMethod(object userdata)
        {
            var method = userdata as MethodInfo;

            if (method == null)
            {
                //Debug.Log("Select Method: None");

                // TODO: select none
                ClearCache();
            }
            else
            {
                //Debug.Log("Select Method: " + method.Name);

                InitMethod(method);

                callMethod.parameters = new FsmVar[cachedParameters.Length];
                for (int i = 0; i < cachedParameters.Length; i++)
                {
                    callMethod.parameters[i] = new FsmVar(cachedParameters[i].ParameterType);
                }

                callMethod.storeResult = new FsmVar(method.ReturnType);

                FsmEditor.SaveActions();
            }
        }
        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();
            }
        }
        private static IEnumerator SaveAllLoadedFSMs()
        {
            feedback.StartProcedure("Save All Loaded FSMs");

            feedback.LogAction("Rebuild Fsm List");

            FsmEditor.RebuildFsmList();

            yield return(null);

            foreach (var fsm in FsmEditor.FsmList)
            {
                //Debug.Log("Re-save FSM: " + FsmEditorUtility.GetFullFsmLabel(fsm));
                //FsmEditor.SetFsmDirty(fsm, false);

                feedback.LogAction("Save action for fsm: " + fsm.GameObjectName + "/" + fsm.Name);
                FsmEditor.SaveActions(fsm);
                yield return(null);
            }

            feedback.EndProcedure("Save All Loaded FSMs");
        }
Esempio n. 5
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();
            }
        }
Esempio n. 6
0
        public override bool OnGUI()
        {
            EditorGUI.BeginChangeCheck();

            EditField("gameObject");

            EditorGUI.BeginChangeCheck();
            EditField("fromOptions");
            if (EditorGUI.EndChangeCheck())
            {
                tweenAction.fromTarget = null;
                ResetSharedParameter(ref tweenAction.fromScale);
                FsmEditor.SaveActions();
            }

            switch (tweenAction.fromOptions)
            {
            case ScaleOptions.CurrentScale:
                break;

            case ScaleOptions.LocalScale:
                EditField("fromScale", "Local Scale");
                break;

            case ScaleOptions.MultiplyScale:
                EditField("fromScale", "Multiply Scale");
                break;

            case ScaleOptions.AddToScale:
                EditField("fromScale", "Add To Scale");
                break;

            case ScaleOptions.MatchGameObject:
                EditField("fromTarget", "GameObject");
                EditField("fromScale", "Multiplier");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            EditorGUI.BeginChangeCheck();
            EditField("toOptions");
            if (EditorGUI.EndChangeCheck())
            {
                tweenAction.toTarget = null;
                ResetSharedParameter(ref tweenAction.toScale);
                FsmEditor.SaveActions();
            }

            switch (tweenAction.toOptions)
            {
            case ScaleOptions.CurrentScale:
                break;

            case ScaleOptions.LocalScale:
                EditField("toScale", "Local Scale");
                break;

            case ScaleOptions.MultiplyScale:
                EditField("toScale", "Multiply Scale");
                break;

            case ScaleOptions.AddToScale:
                EditField("toScale", "Add To Scale");
                break;

            case ScaleOptions.MatchGameObject:
                EditField("toTarget", "GameObject");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            DoEasingUI();

            return(EditorGUI.EndChangeCheck());
        }
Esempio n. 7
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();
            }
        }