Question by
Borsypiusz · Mar 29, 2018 at 11:42 PM ·
variablespassing
Passing two variables does not work - only one is passed
Hey, I need your help. I have a simple code that instantiates a Panel and changes its two text components. My problem - only the header is updated. Well, that depends on the script, sometimes both things can be updated... but I see no reason why.
The code:
public void CreateStandardPanel (string panelHeader, string panelText)
{
Instantiate (StandardPanel, Vector3.zero, Quaternion.identity);
GameObject.Find ("StandardPanelHeaderText").GetComponent<Text> ().text = panelHeader;
GameObject.Find ("StandardPanelText").GetComponent<Text> ().text = panelText;
}
And in a different script I have the following:
public static void PlrDeath (int PlrNumber)
{
string header;
header = "NO WINNER";
string importantMessage;
importantMessage = "the text I want to display";
print(importantMessage);
GameObject.Find ("Sequencing").GetComponent<CreatePanel> ().CreateStandardPanel (header, importantMessage);
}
What is the reason for not displaying "importantMessage" if I can print it? Why does it work in some scripts and in others not?
Comment
Your answer
Follow this Question
Related Questions
Dragging an object to variable: Problems in the editor! 2 Answers
Pass Variable Through C Script 0 Answers
Networking Unity, I need to pass a simple variable value between Client and Server. 1 Answer
How to pass arrays from one object to another? 2 Answers
Calling variables from other script 1 Answer