Calling string from another script - twitch integration,calling string from another .cs - twitch integration
hello,
I'm trying to make it so that my twitch chat can summon a prefab and would like to add their username on top of it.
I've been looking for a couple of days on how to call a string from a different script.
I've managed to get the name of the user that summons it with a specific message.
Unfortunately, when I call the script to create the text above the prefab it returns an empty string.
this is where the string is first called. When challengerName is printed, the proper string appears.
TwitchChat.cs - attached to an empty object called SummonArea
public string challengerName = "test";
public void ReadChat()
{
...
GameInputs(summonMessage,summonName);
}
public void GameInputs(string ChatInputs, string NameInputs)
{
challengerName = NameInputs;
...
}
I created an empty box on top of my prefab with the goal of the text being generated on that instance of the prefab summon. chaName prints out an empty string.
public class ChaName : MonoBehaviour {
private TwitchChat other;
private string chaName = "test";
void Start () {
other = GameObject.FindObjectOfType<TwitchChat>();
chaName = other.challengerName;
Text text = gameObject.AddComponent<Text>();
text.text = chaName;
Font ArialFont = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");
text.font = ArialFont;
text.material = ArialFont.material;
text.fontSize = 100;
text.alignment = TextAnchor.MiddleCenter;
text.color = Color.black;
print(chaName);
}
Am fairly new to C# and Unity, and not to sure how to go about this.
Thank you for any help anyone can provide ♥