Answer the question
In order to leave comments, you need to log in
What is the right way to implement something like this?
I have different objects belonging to the same group (geometric shapes for example). They all have common methods, but there are also unique ones, so it’s more convenient for me to write each figure in a separate file. When I hang up a script on a GameObject, then in order to implement the interaction, I just need to refer to the general methods of the figures. To do this, I want to get the component of the object, but it, depending on the shape, has a different name.
What is the best way for me to access the component?
Shapes implement one common interface.
Answer the question
In order to leave comments, you need to log in
You need to create the most basic class with inheritance from MonoBehaviour and interface (maybe it is not needed), then inheritance will work in the unit for components based on it.
Maybe you should create a library and transfer common methods to it and refer to the library when implementing
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question