Custom inspector and GameObject Children
Hello.
I'm trying to make a custom inspector for my script and right now I'm a bit stuck.
I'm using
EditorGUILayout.ObjectField("Car object", CarObj, typeof(Car), true)
to get an object field with all my "Car" objects. That works great, and I can pick any of the objects, but now I want to be able to choose some children of that object. My "Car" objects have a number of children objects (for example, Wheels1, Wheels2, Spoiler1, Spoiler2, ...), so I'd like them to show in inspector fields, splitting them by type (one for the wheels, where I can choose wheels1 or wheels2, another one for the spoilers, ...). I don't really know the right approach to do this... I tried using
EditorGUILayout.ObjectField("Wheels", blablabla, typeof(Wheels), true);
but that shows all the different wheels for all the cars, and I don't know how the just pick my current selected car wheels.
I also managed to get a List of all the transforms of my GameObject using a Tag, but I can't show that list on an inspector field...
I can't find any clues about how to do this and I really need help...
Your answer
Follow this Question
Related Questions
Is there a way to refer to the only script the object has without naming the script? 2 Answers
How can I move a gameobjects box Collider with another asset? 0 Answers
Scrpits component disappears when I enter playmode 0 Answers
Get component from parent of children hittet with raycast 1 Answer
C# GameObject disabled scripts of its children after SetActive(false) 1 Answer