playMaker

Author Topic: Problem with arrays, OnGUI and EditField  (Read 2537 times)

Trava

  • Playmaker Newbie
  • *
  • Posts: 1
Problem with arrays, OnGUI and EditField
« on: January 15, 2014, 09:04:25 AM »
Hello! Sorry for my bad English!
I wrote an action and an editor for him:
Code: [Select]
[ActionCategory("NEW GUI")]
public class Test : FsmStateAction {
public FsmInt[] arr;
public FsmInt val;
public override void OnEnter()
{
base.OnEnter();
}
}


Code: [Select]
[CustomActionEditor(typeof(Test))]
public class TestEditor : CustomActionEditor {

public override bool OnGUI()
{
EditField("arr");
EditField("val");
return GUI.changed;
}
}

When I try to change the size of the array in the editor - I catch an exception and changes of the array don't save.
The exception is below:
Code: [Select]
ArgumentException: Getting control 4's position in a group with only 4 controls when doing ExecuteCommand
Aborting
UnityEngine.GUILayoutGroup.GetNext () (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayoutUtility.cs:512)
UnityEngine.GUILayoutUtility.BeginLayoutGroup (UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options, System.Type LayoutType) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUILayoutUtility.cs:207)
UnityEditor.EditorGUILayout.BeginHorizontal (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/EditorGUI.cs:5030)
UnityEditor.EditorGUILayout.BeginHorizontal (UnityEngine.GUILayoutOption[] options) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/EditorGUI.cs:5026)
UnityEditor.EditorGUILayout.LabelField (UnityEngine.GUIContent label, UnityEngine.GUIContent label2, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/EditorGUI.cs:4275)
UnityEditor.EditorGUILayout.HelpBox (System.String message, MessageType type) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/EditorGUI.cs:4955)
HutongGames.PlayMakerEditor.StateInspector.DoActionsListGUI (HutongGames.PlayMaker.FsmState state)
HutongGames.PlayMakerEditor.StateInspector.DoActionsPanel ()
HutongGames.PlayMakerEditor.StateInspector.OnGUI ()
HutongGames.PlayMakerEditor.InspectorPanel.OnGUI (Rect area)
HutongGames.PlayMakerEditor.FsmEditor.OnGUI ()
FsmEditorWindow.DoGUI () (at Assets/PlayMaker/Editor/FsmEditorWindow.cs:94)
HutongGames.PlayMakerEditor.BaseEditorWindow.OnGUI ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
UnityEditor.EditorWindow:SendEvent(Event)
HutongGames.PlayMakerEditor.FsmEditor:Update()
FsmEditorWindow:Update() (at Assets/PlayMaker/Editor/FsmEditorWindow.cs:319)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
How using EditField with arrays? Please, help me!

Best regards, Alexey.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Problem with arrays, OnGUI and EditField
« Reply #1 on: January 24, 2014, 07:42:31 AM »
Hi,

 It's OnInspectorGUI() not OnGUI() that you need to use here.

bye,

 Jean