playMaker

Author Topic: FsmStateAction Serialization & PropertyDrawer bug  (Read 3114 times)

lordofduct

  • Playmaker Newbie
  • *
  • Posts: 1
FsmStateAction Serialization & PropertyDrawer bug
« on: August 18, 2014, 11:12:46 PM »
I just purchased PlayMaker last night so that my designer could have a tool like PlayMaker to ease his designing levels. I being the engineer I started tinkering around in it to get a feel for the nuts and bolts before I unleash it on him. I also went and started to make some of my own custom actions when I ran into 2 problems.

1) FsmStateAction serialization - it appears that PlayMaker does not use the unity serialization when serializing the fields of a custom FsmStateAction. Nor does it use .Net/Mono serialization either.

This means I have no way to hook into it.

Furthermore it doesn't look like there is a way to flag a field as non-serialized.

There also doesn't seem to be hooks to latch onto for serialize and deserialize events.

I found this because I needed to reference a 'type' in my custom FsmStateAction, and System.Type isn't serializable by the system. So I quickly wrote up a wrapper around the type to serialize it myself, and it wasn't getting serialized.

My current fix for the problem is that whenever the property in question is set, I immediately serialize the data (it's just a basic string storing the name of the assemblyName and typeName of the Type being referenced). This string gets serialized just fine. Then on the 'Awake' event of the Action I'm deserializing.

This also requires that my serialized field be public (which I guess is how I can restrict what is serialized and not... though I'm unclear as to why the standard System.NonSerialized attribute isn't used instead and you just reflect out all fields as opposed to just public fields...)

This is all fine and well I guess... but it adds the overhead of serializing EVERY time I set the property. And it means I have to make this 'hash' field where I serialize the type to public. Which results in code I just consider to be rather sloppy.



2) PropertyDrawer - I also wanted to create a PropertyDrawer (that is it inherits from HutongGames.PlayMakerEditor.PropertyDrawer) for this Type wrapper I made. It creates a drop down menu for the property in the inspector that includes all the valid types that it can be assigned to. This all works just fine.

I noticed though that the inspector for the action draws the label still even though I have the PropertyDrawer defined for that field. So I end up with:

Quote
Field Label:
Field Label: [....................]

Basically I get the label with nothing to the right of it. Then I get my custom property drawer drawing of the field with the label and what inspector ui I coded for it.

Of course I could just leave out the label part of it. But it's still a bug.

Note, this is for HutongGames.PlayMakerEditor.PropertyDrawer. This does NOT happen when I use HutongGames.PlayMakerEditor.ObjectPropertyDrawer. I am not using ObjectPropertyDrawer for this as that requires FsmObject as the field type in the action, and that requires that my class inherit from UnityEngine.Object, which comes with its own bags of oddities because Unity always returns true if you compare an object that directly inherits from UnityEngine.Object with null (probably because there is no managed memory object in the background associated). And also, probably because of this null test, PlayMaker purges the object from memory as it considers it a memory leak.





Thanks, not sure if I posted this to the correct sub forum. I consider them bugs, so I figured "Bug Reporting" would be the best.
« Last Edit: August 18, 2014, 11:21:28 PM by lordofduct »