- Home /
Invalid index 433 (size is zd) + ArgumentException: Getting control x's position in a group with only x controls when doing Repaint
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:
and this:Invalid index 433 (size is zd) UnityEditor.DockArea:OnGUI()
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,
Answer by gyrosp · Sep 19, 2015 at 06:57 PM
I solved this issue. This seems to be a bug or a 'problem' with unity.
I created a custom Editor for my SerializeableObject which is doing nothing:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditorInternal;
[CustomEditor(typeof(Cart))]
public class CartEditor : Editor
{
}
But it solved the problem and the code is running fine now. This post led me in the right direction:
http://answers.unity3d.com/questions/661360/finally-a-solution-cant-use-guilayout-stuff-in-pro.html