- Home /
Scalable system logic
Let me try to explain! Basically in the system that I'm doing, I would like to:
1- System(my main class) - List<Tools> ToolsList;
| tool01(child class)
2- Tools(parent class)--| tool02(child class)
| tool(n)...
So when i drag new tools in the list, i want to expose to use that child classes functions.Is it possible, or correct?
p.s:The tool01, too02 ... are prefabs.
Answer by NoseKills · Jun 03, 2015 at 07:50 PM
You can access any method that is defined in the Tool class or its base classes, and if the extending class i.e. Tool1 overrides that method, the overriding method will get executed.
You can not call any methods that are only defined in the extending class i.e. Tool1 unless you cast the tool to the type that defines the method. This will of course throw an error if you try to cast a Tool2 into a Tool1, so you have to know what you are referencing.
I solved my problem with ScriptableObjects instances.