Search Unity

GUIText doesn't work anymore, since enter of "Canvas".

Discussion in 'Scripting' started by Temp10101, Mar 2, 2015.

  1. Temp10101

    Temp10101

    Joined:
    Feb 11, 2015
    Posts:
    54
    Most of the time you were able to change your text of GUIText, by saying
    "public GUIText mytexttochange;", I tried to do it, but whenever I add this line, and then I want to drag text into the slot, it denies it, it also denies canvas, such thing as UIText doesn't exist according to Monodevelop and I don't know what to do. The code I have is, but it says that "Text" doesn't exist in current context.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEditor.UI;
    4.  
    5. public class PointCounting : MonoBehaviour {
    6.     public Text PointGUI;
    7.     public int Points = 0;
    8.  
    9.     void Start() {
    10.         PointGUI.text = "Points: " + Points;
    11.     }
    12.  
    13.     void Update() {
    14.  
    15.     }
    16. }
    According to this:


    It should kind of work.
     
  2. Zaladur

    Zaladur

    Joined:
    Oct 20, 2012
    Posts:
    392
    The namespace is UnityEngine.UI, not UnityEditor.UI.

    Code (csharp):
    1. using UnityEngine.UI;
    UnityEditor.UI exists, but you want UnityEngine.UI
     
    Temp10101 likes this.