playMaker

Author Topic: [SOLVED] Flag errors in CustomActionEditor  (Read 273 times)

nickfourtimes

  • Playmaker Newbie
  • *
  • Posts: 27
    • View Profile
[SOLVED] Flag errors in CustomActionEditor
« on: September 25, 2018, 10:27:37 AM »
I've got a custom action, and it's being displayed with a CustomActionEditor.

The action has an FsmGameObject variable, which can either be null, or it can contain a GameObject. In my case, that object has to be a prefab, and it has to contain a specific component, so I can use CheckForComponent().

However, if the variable is empty/null, I get an "Error Editing Action" error. If I drag in any GameObject (whether a prefab, or anything from the scene), I get the CheckForComponent error. (Both errors shown here, apologies for image quality).

Since the variable is allowed to be null, I don't want the "Error Editing Action" error; since I specifically want the object (if it exists) to have a component and be a prefab, the CheckForComponent erroneously adds the ability to add the component to a given GameObject.

What I'd like to do is, in my CustomActionEditor, perform some validation on the variable (isPrefab, hasComponent), only if the variable is not null, and then flag an error from the action editor if there's a problem. However, I'm not sure how to flag these kinds of errors except with the variable attributes, which are giving me the above problems.

Is there a good way to flag config errors in a CustomActionEditor?
« Last Edit: September 25, 2018, 01:54:32 PM by nickfourtimes »

nickfourtimes

  • Playmaker Newbie
  • *
  • Posts: 27
    • View Profile
Re: Flag errors in CustomActionEditor
« Reply #1 on: September 25, 2018, 01:54:19 PM »
Well, that's my own problem solved. I was looking at an older custom action of mine and noticed the override-able ErrorChecker() function. Easy stuff, and no need to even do that in a custom action editor.