I make an array in one script though I want to edit that same array in another script, how do I do this ?
Currently I just return the array to the editing-script in it's Start(). Though when I new the array in the editing-script the array's are no longer linked...
Any way to fix this ? (other than setting the array again in the non-editing-script after I new-ed it in the editing-script ?)
So basecly: How do I keep two array's in two different script constantly sinced.
So when either is changed, the other is immediatly changed too (this is a 2way street).
If you want 'sync' (two copies that update each other), you'd probably want to SendMessage or directly call an syncing function when either array's values change, to the other script.
Script A
public class A
{
public GameObject tiles[,];
.. whatever you need to do in this script ..
}
Script B
public class B
{
void SomeFunction()
{
A scriptA = GameObject.Find("something_with_Script_A_on_it").GetComponent("A");
scriptA.tiles[0,1].someProperty = 1.4;
... etc ...
}
}
Of course, you can also make A a plugin script (put into a Plugins folder) so it's more 'global' and/or you can have an Awake or Start function find an A component script so you only have to do that once.