I have a variable string that I would like to pass into a call to a static script:
I have many different characters, each with a static script:
public class SA_Character_MaleSurvivor02 : MonoBehaviour {
//*********************************************
// Static pointer to this script
public static SA_Character_MaleSurvivor02 Current;
public SA_Character_MaleSurvivor02(){
Current = this;
}
//*********************************************
public GameObject selectionPlane;
public void TurnOnSelectionPlane(){
selectionPlane.SetActive (true);
}
In my SelectionManager, I am using a Raycast to return the name of the object that corresponds to their static script. Once I have the name, how to I go about passing that along? This doesn’t work:
if(Input.GetMouseButtonDown(0)){
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, out hit, Mathf.Infinity)){
if (hit.transform.root.tag == "Human") {
selected = true;
selectedName = hit.transform.root.name;
selectedName.Current.TurnOnSelectionPlane ();
}
}
}
So the issue is, when passing in selectedName (which is the correct name [as a string] I’m trying to use) to the static Current.TurnOnSelection, there is no reference… which I’d expect. But I’m not sure how to make it work…
Thanks, everyone!