Hi Unity Programmers,
I am getting some issue after implementing my own Unity Inspector for a Mono derived class.
Please see attached Pic before:
I have a game object named “CUBE” with a attached script “SingleTaskHandler”. I have a List with variable “InteractionList” (which is again Mono derived class) in it.
I have added reference of 4 scripts of “InteractionBase” class, but my custom editor shows the name of GameObject “CUBE” on all four list items instead showing scripts name “InteractionBase”.
I was trying to understand what your asking but I just can’t seem to get it. I’m pretty good with Editors…
So you want the name to display InteractionBase?
** I understand now… You want the script that you attach to it. Which is a rather odd thing honestly. I’ll think about how this might be able to happen.
So this is kind of what I came up with… I don’t think you can completely replace the Object that you choose but you can choose what to display before it… So I just do a Horizontal() then get the type and put that before the game object link itself.
float thirdOfScreen = Screen.width/3-5f;
for( int i = 0; i < tar.m_interactionListRef.Count; i++)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(" Interface " + i + ": " + tar.m_interactionListRef[i].GetType().ToString(), GUILayout.Width(thirdOfScreen*2));
tar.m_interactionListRef[i] = (InteractionBase)EditorGUILayout.ObjectField("", tar.m_interactionListRef[i], typeof(InteractionBase), true, GUILayout.Width(thirdOfScreen)) ;
EditorGUILayout.EndHorizontal();
}