Z
Z
Zefirot2021-07-11 21:11:55
Unity
Zefirot, 2021-07-11 21:11:55

How to get all objects of another object?

I have an object in which there are others, they all have their own structure, but the common variable is Num, so I need to assign them to each Num.

ObjectCellStatic <-- empty object
--ObjectBase <-- object with class ObjectBase
--ObjectBase
--ObjectCreate <-- object with class ObjectCreate
ObjectCellDynamic <-- empty object
--ObjectMoveBase
--ObjectMoveCreate

something like this structure at the start of the scene, and now you need to sort through all of them and give them numbers, but how to get them, because they are all of different types ...?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Spartanec33, 2021-07-11
@Zefirot

you can inherit all of them from one class, and for the time of enumeration, bring the elements to the base class that has a stupid num field, so to speak, use boxing. The same can be done through interfaces

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question