Hello.
I have a very strange problem and I’m not able to fix it.
I have a ScriptableObject with a member of a custom class with a custom propertydrawer.
I create an asset for this ScriptableObject. If I click on this asset in the editor to modify some values I get this error:
Invalid index 433 (size is zd) UnityEditor.DockArea:OnGUI()
and this:
ArgumentException: Getting control 4’s position in a group with only 4 controls when doing Repaint Aborting
The error vanishes when I remove the member with the custom propertydrawer but of course it is no solution to remove it :).
So I stripped down my code to the absolute basics for debugging purpose but the errors remain and I don’t have the slightest idea how to solve them.
This is my stripped down code:
The ScriptableObject:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Cart : ScriptableObject
{
public LocalizedString localizedCartName; // the errors vanish if I remove this
public Sprite cartImage;
public bool isUnlocked;
}
LocalizedString:
using UnityEngine;
using System.Collections;
[System.Serializable]
public class LocalizedString
{
public string key;
public string GetLocalizedString()
{
//return SmartLocalization.LanguageManager.Instance.GetTextValue(key);
return string.Empty;
}
}
its propertydrawer:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditorInternal;
[CustomPropertyDrawer(typeof(LocalizedString))]
public class LocalizedStringEditor : PropertyDrawer
{
public override float GetPropertyHeight (SerializedProperty property, GUIContent label)
{
return 5.0f;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.indentLevel++;
EditorGUILayout.LabelField("en", "bla");
EditorGUI.indentLevel--;
}
}
This is it. Any idea what is going wrong here?
Edit:
I figured out that the problem is using EditorGUILayout.
Everytime I use it I get these errors. When I switch to EditorGUI it works like a charm.
But why is this. I’d like to use EditorGUILayout as it is far easier to use,