Created
December 9, 2015 18:47
-
-
Save akbiggs/0b779ad9d075fec2ea44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
public class ShowNumberOfCanvasChildren : MonoBehaviour | |
{ | |
private GameObject _canvas; | |
private Text _childText; | |
private void Start() | |
{ | |
// grab an object in the scene called Canvas | |
_canvas = GameObject.Find("Canvas"); | |
// and grab some text in a child of the object | |
// that this script is attached to | |
_childText = this.transform.FindChild("ChildText").GetComponent<Text>(); | |
} | |
private void Update() | |
{ | |
// on every frame, modify that text | |
_childText.text = "Canvas child count: " + _canvas.transform.childCount; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment