Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: coxy17 on June 15, 2018, 09:42:34 AM

Title: Custom action NullReferenceException issue
Post by: coxy17 on June 15, 2018, 09:42:34 AM
I am getting the following error (attached) in my custom action editor only when i go to add it to the FSM from the FSM Action Editor. Any ideas? as it works when I add the action and clear the errors.

seems the issue is with calling the actions variable value before the FSMEditor is open (action.databaseName.Value)

NullReferenceException: Object reference not set to an instance of an object
PMDTAddRowCustomEditor.OnGUI () (at Assets/Scripts/Test/Editor/PlaymakerTestActionEditor.cs:18)

GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Code: [Select]
[CustomActionEditor(typeof(PMDTAddRow))]
public class PMDTAddRowCustomEditor : CustomActionEditor
{

private static PMDTAddRow action;
private bool isDirty = false;
PlayMakerFSM _fsm;

public override void OnEnable()
    {
        action = target as PMDTAddRow;
    }

public override bool OnGUI()
{
isDirty = false;

                FsmString _myDatabaseName = EditorGUILayout.DelayedTextField("Test Field", action.databaseName.Value);

if (action.databaseName.Value != _myDatabaseName.Value){
action.databaseName = _myDatabaseName;
isDirty = BuildFsmVariableList();
}
else if (_myDatabaseName.Value == "")
{
EditorGUILayout.HelpBox("test else if", MessageType.Error);
}

else {
EditorGUILayout.HelpBox("test else", MessageType.None);
isDirty = BuildFsmVariableList();
}

}

}