Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Accessing Booleans from other scripts

$
0
0
Hi im trying to get the hang of changing bools and ints from other scripts. in my case im just trying to change the selected to either 1 or 0. The grid highlight script is attached to multiple cubes who are the children of a empty game object named "Pad" using UnityEngine; using System.Collections; public class MainGUI : MonoBehaviour { public GridHighlight script; // Use this for initialization void Start () { script = gameObject.GetComponent(); } // Update is called once per frame void Update () { } void OnGUI() { if(GUI.Button(new Rect(20, 20, 100, 20), "Cube")) { script.selected = 0; } if(GUI.Button(new Rect(20, 40, 100, 20), "Turret")) { script.selected = 1; } } }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>