- Home /
Display various properties in an EditorWindow
Hi there,
Here is some abstract :
I'm trying to code some basic level design tools for my project. I've got multiple objects of the same type (Tiles) but different nature (TileA , TileB, TileC, all prefabs)
I want to display specific properties of those tiles in an EditorWindow already containing various stuff about the level. Problem is : Each Tile has different properties depending of its nature, let's say .color and .Vector2 for TileA, .strength, .name and .Vector3 for TileB.
To make it work I have this huge ugly switch/case like :
If SelectedTile is a TileA the properties to display are
{some GUICode to display the properties and edit them}
If SelectedTile is a TileB the properties to display are
{some GUICode to display the properties and edit them}
Etc.
Then I have to code some more to apply the changes made by the user to the Tile
To prevent this I tried to separate the GUIcode in each Tile prefabs but it seems I can't execute GUI code for my Editor outside of its class.
I also tried to add a defaultInspector in the EditorWindow but it doesn't seem to work because it's an EditorWindow, not an Editor (am I getting it right ?) but anyway, the main purpose of this EditorWindow thing is to display only specific parameters, not all the transform infos, components etc.
So I'm kinda at loss. Am I not understanding how to use the tools provided ? Is there a workaround ? I'm not asking for a whole coding solution, just some basic concepts about how to work with EditorGUIs while keeping the Editor class "clean".
Answer by Niateph · Oct 18, 2012 at 10:51 PM
Nevermind, you actually can execute some GUIcode for your custom EditorWindow outside of the script. I have no idea why it caused errors in the first place and why it doesn't anymore. I didn't noted the errors throwed so problem solved but no knowledge gained.