Answer the question
In order to leave comments, you need to log in
Is it possible to pass a reference to a variable into an array?
In general, there was a small problem. There is an array which should store references to 2 structures in itself.
[SerializeField] private Stat _health;
[SerializeField] private Stat _damage;
private Stat[] _upgradableStats = new Stat[2] {_health, _damage};
Answer the question
In order to leave comments, you need to log in
Hey!
In general, your idea of \u200b\u200bthis crutch is not entirely clear.
Perhaps you want to sort through the array somewhere further and pull these fields. Question : why?
Moreover, your fields are private.
I suggest you simply reconsider the way you use an object with specified fields.
You will use a class and pull its public fields.
There is no other way to interact with an object to change it (at least I have not heard of such magic yet. Please correct me if there is one).
I remind you that the properties and methods of an object without an "instance" (initialization of a class \ object in memory) will not work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question