Hi, I’m trying to find a way to call methods throughout my project scenes, and not addressing them directly, but finding out which one I need in the process. This is an example of what I have:
private Vector3 setPosition;
private void Update ()
{
if (Input.GetMouseButton(0))
{
setPosition = SetPosition(Input.mousePosition);
}
public Vector3 SetPosition(Vector3 setPosition)
{
Ray ray = Camera.main.ScreenPointToRay(movingPosition);
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo))
{
string name = hitInfo.collider.transform.name; //name = "Thing"
string tag = hitInfo.collider.transform.tag; // tag = "One"
string scene = SceneManager.GetActiveScene().name; // scene = "First"
if (tag == "One")
{
Invoke(scene + "_Manager." + name + "()",0f);
// I need to call First_Manager.Thing(), where First_Manager is another script and Thing() is method in it
}
}
This Invoke doesn’t work obviously. The issue that the script with this code is attached to game object that will be the same throughout many scenes, and I need to address methods in respective scripts attached to game objects from most of them. For example I have scenes First and Second, and they have scripts First_Manager and Second_Manager, can I invoke or call method from there somehow? Thank you.