playMaker

Author Topic: Custom editor for custom action. Trying to use Handles. But....  (Read 309 times)

braincase

  • Playmaker Newbie
  • *
  • Posts: 14
    • View Profile
Custom editor for custom action. Trying to use Handles. But....
« on: December 29, 2018, 09:28:09 PM »
Hi. I'm trying to write a simple custom editor for my action.
It's first time to write a playmaker editor.
Anyway. I read 'moveTowardActionEditor'. I couldn't fully understand but I wrote a simple editor.



This is my status.
1. I tried to visualize 'Vector3[] places' on the scene view using several Handles. - succeed
2. Of course, if I move a handle(for places[0]), The handle's position should be places[0] 's value. - failed

At first, it seems like success.
I can move a handle, the position places[0]'s value looks like updating on action editor.
But, if I click some other object, then get back to my object(has the action), the places[0]'s value will change back to before.

In short, the handle's movement doesn't affect on the real value of variable.


this is my code.(custom editor)
Code: [Select]
        public override bool OnGUI()
        {
            return DrawDefaultInspector();
        }

        public override void OnSceneGUI()
        {
            var positionAction = (HutongGames.PlayMaker.Actions.myPositionAction)target;


            if (positionAction.updatePos()) {
                for (int i = 0; i < positionAction.places.Length; i++)
                {
                    Handles.Label(positionAction.places[i] + new Vector3(0, 1, 0), "place" + i);
                    positionAction.places[i] = Handles.PositionHandle(positionAction.places[i], Quaternion.identity);
                }

                if (GUI.changed)
                {
                    FsmEditor.Repaint(true);
                    FsmEditor.EditingActions();

                }

            }

        }


and this is part of my custom action code.
Code: [Select]
   [Tooltip("Various vector3 places.")]
   public Vector3[] places;

//maybe i shoud do something in the action's code. right?

        public bool updatePos() {
            if (places.Length<=0)
            {
                return false;
            }
            else {

                return true;
            }

 // some action codes below.
           
        }


Oh...please help this poor man~!
« Last Edit: December 30, 2018, 03:49:49 AM by braincase »

braincase

  • Playmaker Newbie
  • *
  • Posts: 14
    • View Profile
Re: Solved by myself
« Reply #1 on: December 30, 2018, 06:38:02 AM »
I don't know well...

Vector3, Vector3[] both don't work with PlaymakerEditor script's handles.
The value wouldn't remain in action editor.

only FsmVector3, FsmVector3[] works with their Value.
Anyway...I struggled for a long time. And learned a little bit.