public static void CreateTextMeshEx() { GameObject go = new GameObject(); go.name = "Text"; TextMeshEx textMesh = go.GetOrCreateComponent <TextMeshEx> (); textMesh.Font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; if (Selection.activeGameObject != null) { go.transform.parent = Selection.activeGameObject.transform; go.transform.position = Selection.activeGameObject.transform.position; } Selection.activeObject = go; }
void Start() { player = Player.Instance; player.OnEnergyPointChanged += OnEnergyPointChanged; player.OnIsHavingKeyChanged += OnIsHavingKeyChanged; timeLabel = gameObject.FindChildByName("TimeLabel").GetComponent <TextMeshEx> (); hearts = new List <GameObject> (); hearts.Add(gameObject.FindChildByName("Heart 1")); hearts.Add(gameObject.FindChildByName("Heart 2")); hearts.Add(gameObject.FindChildByName("Heart 3")); hearts.Add(gameObject.FindChildByName("Heart 4")); hearts.Add(gameObject.FindChildByName("Heart 5")); for (int i = 0; i < hearts.Count; i++) { hearts[i].SetActive(false); ShowHeart(hearts[i], i * initialHeartApparitionDelay); } SetLifes(Player.Instance.EnergyPoints); key = gameObject.FindChildByName("Key"); key.SetActive(false); }