Hi, firstly I say that I have tried many variations in order to get this to work nd have no luck. Have searched the forums until I was blue in the face. Can someone please help with this niggle… please.
In the scene I have created an empty, to which several C# scripts are attached. They are all located in the same directory. The main C# Class calls the other public class scripts and the relevant procedures located in each.
The structure is represented below as the first Script calling a function in the the second Script/Class which needs to return a value to the first.
What am I missing or doing wrong. Your help would be greatly appreciated.
First cs file
public class PlayerMenu : MonoBehaviour {
....
void OnGUI () {
...
if(CheckValidInput.CheckValidInputFromX(BoardArray.MoveFromX)){
GUI.Button(new Rect(10,200,240,20), "Execute Move", GUI.skin.button);
}
}
Second cs file looks something like this.
public class CheckValidInput : MonoBehaviour {
....
public bool CheckValidInputFromX(string MoveFromX){
int x = 0;
bool ValidInputFromX = false;
switch(MoveFromX){
case "a":
x = 1;
break;
case "h":
x = 8;
break;
default:
x=0;
break;
}
if((x>0) (x<9)){
ValidInputFromX = true;
}
else
{
ValidInputFromX = false;
}
return ValidInputFromX;
}
....
}
Many Thanks