- Home /
can´t link a gui text to my script
hey guys im new to unity and i got the following problem : (i use unity 5.0 so i didnt found any usefull tutorials) i want to edit a GUIText with my script but when i try to link my GUIText to my variable in the script it basicly do not work and im not sure what i did wrong (i already did it with a normal sphere and it works so basicly i know how it is supposed to work) would be rly nice if u can help me out:) (here is my script may i did there something wrong aswell)
the script is about moving a sphere and collect some objects so your score increases and yeah the i cant eddit the guitext to display the score using UnityEngine; using System.Collections;
public class PlayerMovement : MonoBehaviour { private int count; public GUIText countText; //this is the variable i want to be linked public float speed; public Rigidbody rb; void Start() { rb = GetComponent (); count = 0; countText.text = "Count: " + count.ToString (); } void FixedUpdate () { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); rb.AddForce (movement * speed); } void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Pick-Up") { other.gameObject.SetActive (false); count = count + 1; countText.text = "Count: " + count.ToString (); } } }
HI I second this, not sure about you $$anonymous$$itokid but im trying the rolling ball tutorial off unity site -
the part where you create a GUIText and set its value in the code you cant then drag a text panel on to the players counttext variable as it needs a GUI text and there does not appear to be a GUI Text component anymore ??!
do we use UI and change the code - bit of a newbie here
Hi,
You should find some useful hints here: http://answers.unity3d.com/questions/937681/how-do-i-pop-up-a-canvas-when-a-click-some-key-fro.html
But ins$$anonymous$$d of a Canvas you want to use a Text and you don't need the "press on a key" part.
Thanks :) just found the part about using render to create a new GUI text which works
Thanks for reply
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to change font size in ongui function 0 Answers