- Home /
adding GUI text in 4.6.1f1
im following the beginning tutorial "roll-a-ball" using unity version 4.6.1f1 im currently on lesson 7 "displaying text". while going through the lesson the video tells me to add a GUItext.. so i go to gameobject... i see no GUI text tab...so i figure ok go to UI tab..and i see a text option..so i click it...then from their its all messed up.. plz help
if u want the link to the video it is link text my issues start @ 1:50
thx u in advance
Answer by Kiwasi · Jan 22, 2015 at 09:34 AM
Forget GUIText, there is no particular reason to learn to use a GUIText any more. There is an updated version of the video here.
Find? I got frustrated at answering this question so I rewrote the tutorial for 4.6
You know that bit where people write lol but haven't actually laughed out loud. The opposite of that! :-)
Cheers @Bored$$anonymous$$ormon
Answer by Mmmpies · Jan 21, 2015 at 02:25 PM
Click on Add Component on your empty gameObject as GUIText is still available in 4.6 just not in the same place.
EDIT
Did you set the transform to origin like it says in the video?
Click on Add Component on your empty gameObject as GUIText is still available in 4.6 just not in the same place.
ok that kinda worked... but now its not displaying in the game screen...ive added text into it anchored to the upper left where i would want it... made bright red text (so it will stand out for now) size 50 font (so it can stand out...)
Answer by Mischief Manager · Feb 23, 2015 at 05:48 AM
EDIT: Beginner here, having similar issues getting the GUItext to appear in the Character Controller script in Inspector.
The updated video linked to youtube didn't work for my either, and in following Richards instructions I now have more errors to work around.
Basically, the script didn't' work, so I tried closing down and reopening Unity and now I see an error in the Player Controller script within Inspector which says the "script can't be loaded". Upon opening the script is gives me another error, "Object reference not set to an instance of an object."
Also might as well mention it, not sure what this means, but I noticed that whilst editing the Character Controller script using the newer Lesson video, when creating the new "public text countText" variable, there are no completions for "text" that show up for me, and the word appears red instead of blue after the line of code is finished. Specifically, it says "no completions found" when typing in. I noticed this was not the same for Richard in his video. It does turn blue when I capitalize to "Text" but i get the same errors..
Oh well, it sucks that I can't finish this today, I might as well move on to another Lesson and just keep working at Unity. I'll save the project for later date so if anyone bothers to make sense of this I'll complete it.
EDIT 2: Wow. So the parsing error i was troubleshooting, specifically "error CS0246: The type or namespace name `text' could not be found. Are you missing a using directive or an assembly reference?", i have been working on it for hours. Rewriting lines of code, capitalizing, lowercasing, searching the net for advice etc. Just now I retyped the line and it just worked. No more errors and the word "text" was recognized as reference finally. Very silly. The Count Text option appeared the Player Controller section for me and I'm finally good to move on. yay.
Here is my script below for anyone having the same problem. This is playable for me with no errors.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class PlayerController : MonoBehaviour{
public float speed;
private int count;
public Text countText;
void Start (){
count = 0;
SetCountText ();
}
void FixedUpdate (){
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 Movement = new Vector3 (moveHorizontal, 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: " + count.ToString ();}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613181025im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make a FLASH 4 Answers
How Do I Make My Player Fall Through? 1 Answer
Unity 4.6 - Interactable UI Elements 1 Answer
[4.6 GUI] Source of event 1 Answer
Unity 4.6 - Editor Scripting - Add Reflection Method as a Persistent Listener 1 Answer