Does anyone know how i would be able to access functions in other scripts by a string?
so the idea behind this is in the inspector on the second script i just enter in the string section what function i want to call from its root script instead of have to manually coding rootScript.valueOne, rootScript.valueTwo or rootScript.valueThree in the second script.
I’ve tried rootScript, rootScript.(calledFunction), rootScript.“calledFunction”.
so far nothing is working
script one
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class scriptOne : MonoBehaviour {
public int valueOne;
public int valueTwo;
public int valueThree;
void Start () {
}
void Update () {
}
}
script two
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class scriptTwo : MonoBehaviour {
public scriptOne rootScript;
public int testInt;
public string calledFunction;
void Start () {
}
void Update () {
testInt = rootScript.calledFunction;
}
}