hey people,
i’m trying to create an array with transforms which i can edit or read through another script.
to do this i got to make it a static. but when i type static infront of the variable, it disapeares in the inspector, which is normal.
but now i want to shove some transforms into this array via the inspector, but i cant cause its a static!
how do i fix this?
script i’m using:
public Transform[] MeleeWeaponCase;
bunch of thanks.
Rather than make the array static you should make a singleton - so you have one of these in the scene but a way of finding it quickly:
public static YourScript instance;
public Transform[] MeleeWeaponCase;
void Awake()
{
instance = this;
}
The from elsewhere
var weapon = YourScipt.instance.MeleeWeaponCase[0];
You could create another array that isn’t static, put the transforms in that array and then run:
for(int i = 0; i < NonStaticMeleeWeaponCase.Length; i++){
MeleeWeaponCase _= NonStaticMeleeWeaponCase*;*_
}
P.S I’m not a master as C# (I just started learning yesterday), so sorry in advance if there are any errors in that.