Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2010
    Posts
    1

    Post Unknown problem with GUI

    Hi, I'm doing the tutorial for unity for the 2.5D space invador / Galaga game, and im up to were we start scripting the lives and score. When i save my script, i get no errors, but the lives / score doesn't show up when i play the game. I'm sorry to post a script, so you can skip it if you need to. (This is the player script for were i'm up to, its C#)

    using UnityEngine;
    using System.Collections;

    public class Player : MonoBehaviour {
    //__________________________________________________ ______

    //Graphical User Interface
    void onGUI()
    {
    //calculates from the upper-left corner of screen
    GUI.Label (new Rect (10, 10, 60, 20), "Score: " + Player.Score.ToString());
    GUI.Label (new Rect (0, 30, 60, 20), "Lives: " + Player.Lives.ToString());
    }
    }
    Last edited by fatgav; 05-03-2011 at 01:45 AM.

  2. #2
    Join Date
    Aug 2010
    Location
    Las Vegas, NV
    Posts
    12
    I think these are the GUI coords for that game. Is the text maybe hidden or off screen because you aren't using the correct ones?

    Code:
        void OnGUI()
        {
            GUI.Label(new Rect(10, 10, 120, 20), "Score: " + Player.Score.ToString());
            GUI.Label(new Rect(10, 30, 60, 20), "Lives: " + Player.Lives.ToString());
        }

  3. #3
    Join Date
    May 2008
    Location
    Suomi/Finland
    Posts
    1
    Just change void onGUI() --> void OnGUI()

  4. #4
    Join Date
    Aug 2010
    Location
    Las Vegas, NV
    Posts
    12
    Quote Originally Posted by Partikkeli View Post
    Just change void onGUI() --> void OnGUI()
    Or that... =)

  5. #5
    Join Date
    Aug 2010
    Posts
    1
    Durh, just did the same thing. Not used to the harsh realities of function calls.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •