I've been struggling with a method that needs to check, and then change a variable that is from a separate script and object. I'm trying to check an array for entries that are not null, and entries that are not already used in my placeholders. When both of these are true, it's supposed to copy the contents of that array into my actualReadIn string variable, which is held in another script. Categories is the string array I'm reading from.
Here is the code I have:
int checkForNotNull(string[] a)
{
for (int x = 0; x < a.Length; x++)
{
if (a[x]!= "" && orbScript1.actualReadIn != a[x] && orbScript2.actualReadIn != a[x] && orbScript3.actualReadIn != a[x] && orbScript4.actualReadIn != a[x]
&& orbScript5.actualReadIn != a[x] && orbScript6.actualReadIn != a[x]&& orbScript7.actualReadIn != a[x] && orbScript8.actualReadIn != a[x])
//^^ This should both check to see if the entry is not nothing, and see if the entry matches any others orbs.
return x;
}
return -1;
}
^^ This code checks to ensure that the other placeholders don't already contain the array entry
void readArray(string actualRead)
{
if (taskPhase == 1)
{
if (actualRead == "")
{
actualRead = Categories[checkForNotNull(Categories)];
}
}
if (taskPhase == 2)
{
}
}
^^ The argument on this script is supposed to be orbScript1.actualReadIn. Which is a string variable I'm trying to fill. The issue comes when I try to call the method
readArray(orbScript1.actualReadIn);
There's no errors with this, but it isn't filling the value on orbScript1. I'm pretty new at this, so if I'm doing something that is bad form or isn't common practice let me know.
If you need clarifications I'll do what I can to provide it.
Thanks.