Loosing references when going in playmode
I have a script in a game object that references a script of another game object and a UnityEngine.UI.Text of another one. If I set the references during playmode it works fine. But if I set them in edition mode, then when I hit 'play' the two references are lost (images below).
You can see that GMscript has the two references in the first image and then in the second image (playmode) they have disapeared.
Here you have GMscript :
#pragma strict
var PScript : PlayerScript;
var txt: UnityEngine.UI.Text;
function Start () {
txt = gameObject.GetComponent.<UnityEngine.UI.Text>();
PScript = GetComponent (PlayerScript);
}
function Update () {
txt.text = "Gold:" + PScript.gold;
}
Your answer
Follow this Question
Related Questions
Going back to MainMenu from other level. (Problem) 0 Answers
Unwanted behavior when manipulating a public integer from a different script: How can it be fixed? 1 Answer
How to use DateTime.now (Local) with multiple daily Time Ranges to use for Day/Night Cycle? 0 Answers
Editor script modify scene, but changes dont want to be saved 1 Answer