这是一些代码:
public class Script_Console: MonoBehaviour {
public string clickedButtonName;
public string save_click_name;
void Update() {
save_click_name = clickedButtonName;
UnityEngine.Debug.Log ("Before: printing in update method save click name" +save_click_name);
}
}
我正在尝试将clickedButtonName
分配给save_click_name
,但无法第二次获得该值。
答案 0 :(得分:0)
您的问题并不完全清楚,但save_click_name
应该具有clickedButtonName
中设置的任何名称。为清晰起见,您可以尝试下面的示例
void Update () {
if(save_click_name != clickedButtonName)
UnityEngine.Debug.Log ("Before: printing in update method save click name" + save_click_name);
save_click_name = clickedButtonName;
if(Input.GetKeyUp(KeyCode.A)) {
int rand = UnityEngine.Random.Range(0,10);
clickedButtonName = "something " + rand.ToString();
}
}