Saturday, February 16, 2019

Unity 3d Count Objects full script by allunityscripts

Count Objects

unity 3d count objects



using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CountObjects : MonoBehaviour {
    public string nextLevel;
    public GameObject objToDestroy;
    GameObject objUI;
// Use this for initialization
void Start()
    {
        objUI = GameObject.Find("ObjectNum");
    }
// Update is called once per frame
void Update () {
        objUI.GetComponent<Text>().text = ObjectsToCollect.objects.ToString();
        if (ObjectsToCollect.objects == 0)
        {
            Application.LoadLevel(nextLevel);
            //Destroy(objToDestroy);
            objUI.GetComponent<Text>().text = "All objects collected.";
        }

}
}

No comments:

Post a Comment