- Home /
 
Why the text and the UI code is can't applying
Why the text and the UI code is can't applying ? i can't apply the Ui code when i press apply in the block and the block is generated in time the ui code is not applying my codes
Enemy ((Block))
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Enemy : MonoBehaviour {
 public float health = 5;
 public GameObject Enemys;
 public UI ui;
 public int BulletCounter = 1;
 public int MoveTimes = 90000000;
 void Awake()
 {
     health = Random.Range(1, 5);
     StartCoroutine(RigidbodyEdit());
 }
 void Damage(int dmg)
 {
     health -= dmg;
     BulletCounter += dmg;
     ui.Score++;
     Debug.Log(ui.Score);
 }
 void Update()
 {
     if (health <= 0)
     {
         Destroy(gameObject);
     }
 }
 IEnumerator RigidbodyEdit()
 {
     for(int i = 0; i < MoveTimes; i++)
     {
         yield return new WaitForSeconds(0.5f);
         Destroy(GetComponent<Rigidbody2D>());
         yield return new WaitForSeconds(1f);
         Enemys.gameObject.AddComponent<Rigidbody2D>();
     }
 }
 
               }
UI code
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class UI : MonoBehaviour {
 public Text ScoreUI;
 public static int ScorePlus;
 public int Score;
 void Update()
 {
     ScorePlus = Score;
     ScoreUI.GetComponent<Text>().text = (ScorePlus.ToString());
 }
 
               }
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Item name UI/GUI text over item/enemy in 3d 1 Answer
if statement not working for user input 0 Answers
Multiple Cars not working 1 Answer
Quick Question on UI Text Alignment 1 Answer
Positions of UI Text characters. 0 Answers