I have a
StageScript in which I am filling an array in the inspector named
UnorthodoxSeats marking it as
[SerializeField] protected GameObject UnorthodoxSeats in the script. When the script runs, after some time a Character is instantiated to move towards the seat. The Character has also a script named
CharacterScript which is the derived class of
StageScript. Now, In the
CharacterScript whenever I get
UnorthodoxSeats.Length it shows
0. I am confused why?
Any help would be awesome.
Hi, @OsamaSany! I suppose that you work with two different instances.
One instance is type of StageScript, where you filled field.
And another instance is type of CharacterScript, which has empty field, because it is other instance.
If you need to share field between classes - use static field!
Yes I think it was that. I made the array public and created a place holder for Stage in the character script and accessed it as the characters great grand parent and accessed the stage script and array from that place holder and it is working fine now.