Hi there,
I’m currently dabbling with the CustomPropertyDrawer functionality and can’t figure out the following (minimized) problem:
Lets say I have a Scriptable Object with a custom (for convenience) inner class
[CreateAssetMenu(fileName = "Test", menuName = "ScriptableObjects/Test", order = 2)]
public class Test : ScriptableObject
{
public InnerTest MyTest = new();
[Serializable]
public class InnerTest
{
public string a = "Hello";
public string b = "World";
}
}
I want to make the two strings a and b editable with a TextField, so I created a new drawer:
[CustomPropertyDrawer(typeof(Test.InnerTest))]
public class TestDrawer : PropertyDrawer
{
public override void OnGUI(Rect Position, SerializedProperty InnerTestProp, GUIContent Label)
{
Rect Rect1 = new Rect(0, 0, 100, 20);
Rect Rect2 = new Rect(0, 25, 100, 20);
SerializedProperty AProp = InnerTestProp.FindPropertyRelative("a");
SerializedProperty BProp = InnerTestProp.FindPropertyRelative("b");
AProp.stringValue = EditorGUI.TextField(Rect1, AProp.stringValue);
BProp.stringValue = EditorGUI.TextField(Rect2, BProp.stringValue);
}
}
which looks decent
but for some reason I can only edit the first Textfield. Only "Hello" is selectable or changeable.
I guess I am missing some config somewhere, I’d be glad for a hint.
Thanks
Edit:
Funnily enough with EditorGUILayout.TextField its working, but I wanted to use the non-layout version to have manual placing ![]()
