This question has already been answered:
Good day. There are 2 .cs scripts. The first script displays a brief information about the task:
public bool quest1; public Text quest1Text; public void Start() { quest1 = false; quest1Text.text = ""; } public void OnCLick_Button() { quest1 = true; if (quest1) { Debug.Log("Задание взято"); quest1Text.text = "Например - что бы выполнить задание, необходимо прочитать книгу."; } }
The second script, as planned, should change the Quest1 boolean variable:
public void OnMouseDown() { AcceptQuest.quest1 = false; }
If I make variables static in the first file, then the Boolean and text variables will not be displayed in the object inspector. Ie when I start, I get a warning that there are no objects to show. The question is, how do I transfer the value from one script to another?
Thanks for the help, Amateur.
var go = GameObject.Find("someGameObjectOnScene").gameObject.GetComponent<YourComponent>()
and manipulate throughgo
...go.quest1 = false/true;
..... And if the static variables, then immediatelyvar questVar = Somescript.quest1;
............ and in the inspector are not displayed because static variables belong to the class and not to the object .... and you can throw a component on many prefabs ... ... and as in In this case, the unit must resolve the situation and at the same time so that you do not get confused that this variable is a class and not an object? - Alexey Shimanskystatic
modifier declared variables disappear from the inspector, but the point is that the variables work even in this case. Therefore, I just added task status statuses (a regularint
variable) and was able to solve the problem with getting, executing and returning the task. - AmateurSuctomEditor
.... what are you looking for ... Only this is a crutch rather than a solution ... good luck with development - Alexey Shimansky