Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[Solved] Question - Show score

Discussion in 'Scripting' started by kholyphoenix1, Nov 12, 2015.

  1. kholyphoenix1

    kholyphoenix1

    Joined:
    Apr 17, 2015
    Posts:
    57
    Hello,

    I created a script in ".js" but do not know on the screen to display the score for each item collected in the game.
    I know I need to use "text canvas".

    Could someone help me?
    Thank you!

    ---









     
    Last edited: Nov 12, 2015
  2. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
  3. kholyphoenix1

    kholyphoenix1

    Joined:
    Apr 17, 2015
    Posts:
    57
    Right.
    I follow the tutorial wanted to warn both.
    1º First my English is not so good.
    2º The stars gathered in my game are not pointed in the game.

    ---







     
  4. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Although I cant see the error in the console.

    Looks like you have to do the same for the WinText as you have done with the score.

    Add another UI Text object to your canvas for WinText.
    Once that is created drag it into the WinText slot you have in the inspector.

    Possibly looks like you are trying to use Wintext and its not been set up.
     
  5. kholyphoenix1

    kholyphoenix1

    Joined:
    Apr 17, 2015
    Posts:
    57
    I know but it does not solve the problem.
    The video does not show anything about the cube object it touches.
    A script in character does not solve everything.
    As the cube object is being deleted? This video does not show.
     
  6. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
  7. kholyphoenix1

    kholyphoenix1

    Joined:
    Apr 17, 2015
    Posts:
    57
    Ahhh!
    Thanks a lot!
     
  8. rchmiel

    rchmiel

    Joined:
    Apr 5, 2015
    Posts:
    49
    You can also use code (put this on your script, of course use your variables):
    Code (csharp):
    1.  
    2. var points : float;
    3. var info : string = "Score: ";
    4. var rect : Rect; // set in Inspector where you want to display gui and how big must be
    5.  
    6. function OnGUI()
    7. {
    8.    GUI.Label(rect, info + points);
    9. }
     
  9. kholyphoenix1

    kholyphoenix1

    Joined:
    Apr 17, 2015
    Posts:
    57
    rchmiel, Thanks !! :D
     
  10. rchmiel

    rchmiel

    Joined:
    Apr 5, 2015
    Posts:
    49
    will be usefull?
     
  11. kholyphoenix1

    kholyphoenix1

    Joined:
    Apr 17, 2015
    Posts:
    57
    I'm watching some videos first.
    I do not know to program in C # yet.
    But I want to thank you :D

    ---

    Solved!!
     
    Last edited: Nov 13, 2015
    OboShape likes this.