playMaker

Author Topic: PropertyDrawer  (Read 2491 times)

BGL

  • Playmaker Newbie
  • *
  • Posts: 4
PropertyDrawer
« on: March 14, 2014, 09:54:21 AM »
Hi, I want to customize how a type is drawn in the state window.
I wrote this code:
Code: [Select]
using PropertyDrawer = HutongGames.PlayMakerEditor.PropertyDrawer;

[PropertyDrawer(typeof(MyType))]
public class MyTypePropertyDrawer : PropertyDrawer
{
public override object OnGUI(GUIContent label, object obj, bool isSceneObject, params object[] attributes)
{
Debug.Log("OK MyTypePropertyDrawer WORKS");

MyType myObject = obj as MyType;
GUILayout.BeginVertical();

                GUILayout.Label(myObject.myStringField);

                GUILayout.EndVertical();

                return obj;
}
}

public class TestAction : FsmStateAction
{
public MyType myObject;
}

I expect to see TestAction in the editor showing just a label with the value of myObject.myStringField, but the property drawer is never called (the log doesn't show up).
How it is supposed to be used the HutongGames.PlayMakerEditor.PropertyDrawer class?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PropertyDrawer
« Reply #1 on: April 02, 2014, 07:18:00 AM »
Hi,

 For this, you will need to use PlayMaker custom editor, they are separate from the action or property class ( cause they only run in editor, not at runtime).

you can look at "iTweenMoveToActionEditor" class in iTween/Playmaker/editor for an example.

Bye,

 Jean