- Home /
accessing to one array from another script
Hi all; I have an array in one script, and I have to access it in another script. I fill the array in script "A" like this:
@RPC
function IsAvailable() {
while (count < 13)
{
RandNo = Random.Range(1,13);
for(i=0; i<13; i++) {
if (RandomCardNO[i] == RandNo) { break; }
else
{
RandomCardNO[i] = RandNo;
count++;
}
}
}
for(i=0; i<13; i++)
IsGained[i] = false;
}
I want to access to the RandomCardNO[] in script"B" (both the server and clients). I try to access it in script "B" in update function.
How can I do it?
Answer by BiG · Jan 19, 2012 at 07:06 AM
If RandomCardNO is declared in script B, and both A and B are attached to the same object, you can do the following in A, to retrieve that:
RandomCardNO_temp = GetComponent(B).RandomCardNO;
Answer by Mohammadjavad · Jan 19, 2012 at 03:03 PM
My problem is that A and B are attached to the different game objects.
In that case,
RandomCardNO_temp = GameObject.Find("other_object_name").GetComponent(B).RandomCardNO;
Please, use comments next time, to reply.
Your answer
Follow this Question
Related Questions
RPC to a single client 1 Answer
Download an image from a local device 0 Answers
UNET Discrete Server/Client. ClientRPC? Command? 3 Answers