- Home /
how do i attach GUITEXT to a prefab
Hey guys, how do i attach a GUITEXT do a prefab, its important because one of the prefab gameobjects detects collision which has an effect on the score, but it wont let me drag the GUITEXT onto the script slot.
Comment
Answer by robertbu · Dec 02, 2013 at 05:31 PM
The typical way is to initialize it in Start() on a script in your prefab using GameObject.Find():
private var score : GUIText;
function Start() {
score = GameObject.Find("Score").guiText;
}
This assumes the game object with the GUIText for scoring is named 'Score'. Change as appropriate.
Your answer
Follow this Question
Related Questions
GUIText not updating score.... 1 Answer
Pairing and GUITexture with a Timer? 1 Answer
Distribute terrain in zones 3 Answers
Adding scores/numbers? 1 Answer
using playerprefs to update a guitext and record highscores 1 Answer