playMaker

Author Topic: Custom action editor problem  (Read 4434 times)

N3uRo

  • Playmaker Newbie
  • *
  • Posts: 10
    • View Profile
Custom action editor problem
« on: May 18, 2013, 01:26:48 PM »
Hi,

I'm trying to make a custom action editor.

I want to change a string field to appear as a Popup that I generate from a file.

My problem is that the inspector class changes this string field value and this field must not be seen in the action inspector.

I have "HideInInspector" attribute but PlayMaker seems that ignores it.

If I change the field to be a property it seems that it doesn't store the value correctly (doesn't get serialized).

Help, please!

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3205
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Custom action editor problem
« Reply #1 on: May 18, 2013, 04:35:57 PM »
Can you post what you have so far?
Have you looked at the example:
https://hutonggames.fogbugz.com/default.asp?W1104

N3uRo

  • Playmaker Newbie
  • *
  • Posts: 10
    • View Profile
Re: Custom action editor problem
« Reply #2 on: May 19, 2013, 02:27:39 AM »
Yes, it was the first thing I did. I read the release notes and it was a link to that example.

Here is a screenshot:



  • The first one is the one that I want to hide. This is my problem, I don't want to show that field. (I wrote the "HideInInspector" attribute but seems to ignore it)
  • The second one is the variable to store the value.
  • The third one is the "EditorGUILayout.PopupField" that I generate from a file. When I change the value on this field it write it on the first field.

Another question, why there is no "OnDisable" or "OnDestroy" like the Unity Editor class?

http://docs.unity3d.com/Documentation/ScriptReference/Editor.html

Because I need to do some stuff when the action editor it's destroyed.

Thanks!
« Last Edit: May 19, 2013, 02:29:52 AM by N3uRo »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3205
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Custom action editor problem
« Reply #3 on: May 19, 2013, 06:42:29 AM »
CustomActionEditor is only loosely based on the Unity Editor class. It does not implement Editor. So don't expect Editor attributes to work with CustomActionEditor ;)

If you need to hide a field, don't use DrawDefaultInspector.

Use EditField(fieldName); to draw each field you want to show.
E.g. EditField("Text");

Or you could go even lower level and just use EditorGUI controls directly.
E.g., myAction.text = EditorGUILayout.TextField...

There is no way to manually draw the variable controls though.
And no OnDestroy yet.
These use cases didn't come up in the beta.
With he first release I wanted to handle the most common use cases, then add what people needed...

Can you post the action you're trying to build an editor for?

N3uRo

  • Playmaker Newbie
  • *
  • Posts: 10
    • View Profile
Re: Custom action editor problem
« Reply #4 on: May 19, 2013, 09:25:44 AM »
Ok, thanks.

Instead of using "DrawDefaultInspector" I replaced it for "EditField("text")" because it's the only field that I wanted to appear on the inspector.

But I really need a "OnDestroy", please!!

Thanks!!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Custom action editor problem
« Reply #5 on: May 19, 2013, 10:35:19 PM »
Hi,

 Interested to know the use case for OnDestroy as well.

bye,

 Jean

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Custom action editor problem
« Reply #6 on: May 20, 2013, 04:58:34 AM »
I really need a "OnDestroy", please!!

Can't you just put the actions you want it to do before it runs the destroy? Or encase it in a wrapper and destroy the child while the wrapper runs the on destroy actions?

N3uRo

  • Playmaker Newbie
  • *
  • Posts: 10
    • View Profile
Re: Custom action editor problem
« Reply #7 on: May 21, 2013, 09:20:17 AM »
I really need a "OnDestroy", please!!

Can't you just put the actions you want it to do before it runs the destroy? Or encase it in a wrapper and destroy the child while the wrapper runs the on destroy actions?

That's my problem, there is no "OnDestroy" message sent by PlayMaker so I don't have a place to put my code...

I'm always talking about code that I want to execute in the action editor, not the action itself.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3205
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Custom action editor problem
« Reply #8 on: May 21, 2013, 09:22:20 AM »
CustomActionEditor has OnDisable in 1.6.1 (coming soon).

N3uRo

  • Playmaker Newbie
  • *
  • Posts: 10
    • View Profile
Re: Custom action editor problem
« Reply #9 on: May 21, 2013, 09:48:06 AM »
CustomActionEditor has OnDisable in 1.6.1 (coming soon).

Ok, thanks!!

Igmon

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Re: Custom action editor problem
« Reply #10 on: June 12, 2013, 03:46:02 AM »
I would second on the ability to hide a variable from inspector when using DrawDefaultInspector.

There are times when I want specific control for public variables, either that or allow serializing non-public variables.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3205
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Custom action editor problem
« Reply #11 on: June 14, 2013, 10:26:35 AM »
I agree this would be useful.

In the meantime you can use EditField("fieldName") to expose each parameters you want to edit, instead of using DrawDefaultInspector(). Not as convenient, but same end result...  :P

rik

  • Full Member
  • ***
  • Posts: 247
    • View Profile
Re: Custom action editor problem
« Reply #12 on: August 01, 2017, 03:06:50 PM »
Hi i need c# sample for this i tried and i did not got a way to do this :(

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3205
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Custom action editor problem
« Reply #13 on: August 01, 2017, 08:14:23 PM »
Have you looked at the doc posted earlier:
https://hutonggames.fogbugz.com/default.asp?W1104