I followed the tutorial and rendered a GUItext and my code is exactly the same, with the exception of adding using UnityEngine.UI; at the top. When I press play, I get:
Count: GUIText(UnityEngine.GUIText)
I looked at other answers and I couldn’t find the answer to this one. Here is my code:
using UnityEngine.UI;
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public float speed;
public GUIText countText;
private int count;
void Start()
{
count = 0;
SetCountText ();
}
void FixedUpdate() //For Physics
{
float moveHorizantal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3(moveHorizantal, 0.0f, moveVertical);
rigidbody.AddForce(movement * speed *Time.deltaTime);
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "PickUp")
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText ();
}
}
void SetCountText()
{
countText.text = "Count: " + countText.ToString();
}
}