Greetings!
I have a data flow shown here:
And I have a number of gamobjects on the scene. I want to edit(in Edit Mode/not play mode)each object individually. Each object has a component named ObjectDataHolder that is declared in a following way:
public class ObjectDataHolder : MonoBehaviour
{
public ScriptableObject data;
}
The process of editting is this: I select object and click in context menu to edit it. Then a number of tools should be loaded into the current editor window(all stuff happens in editor window). The objects are different some are buildings, some are just static objects and others.
I want to show tools(within editor window) respective to the type of object I am editting at the moment. So the type of the object is the type of data. So if ObjectDataHolder.data type is BuildingData I want to show tools for buildings.
I could do the following:
ObjectDataHolder dataHolder = selectedGameObject.GetComponent<ObjectDataHolder>();
if (dataHolder.data is ProductiveBuildingData)
ShowToolsForProductiveBuildings();
else if (dataHolder.data is BonusBuildinData)
ShowToolsForBonusBuildingData();
else if ...
But this is not very convenient as when I add some more data types I would have to add code here as well.
Is here some better approach to use ?
Thank you in advance.