E
E
EvGenius Karlonius2021-05-18 00:03:59
Unity
EvGenius Karlonius, 2021-05-18 00:03:59

What is the correct way to write a two-dimensional array without new?

There is such a line
public FlowerPRO[,] flowersPRO = new FlowerPRO[MAX_FLOWERS_X, MAX_FLOWERS_Y];
Says you can't use new because of MonoBehaviour

FlowerPRO[,] flowersPRO = gameObject.AddComponent();
Tell me how or where to write brackets from the array on the right side?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Kachan, 2021-05-18
@MANAB

If your FlowerPRO inherits from MonoBehaviour, then everything is correct. Or remove inheritance, or create List/Array through the inspector and pass where it is necessary. And the announcement can be written simplypublic FlowerPRO[,] flowersPRO = null;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question