GUI text like GTA

Hello Everyone! Im new in unity3d and currently working hard for my thesis about 3d vle implementation in our school. I can i pick up an object and then it it gives me amount of points in the other hand the points are displayed in GUI text. Just like in GTA: Vice City that if Tommy picks up money it adds value to the gui text intended for current money. Please help its for my thesis purpose and i am working very hard for it.

more ▼

asked Jul 16, 2011 at 06:38 PM

JamesReubenGruta gravatar image

44 16 11 19

What parts work and don't work right now?

Jul 16, 2011 at 06:47 PM Peter G

What do you need help with?

Jul 16, 2011 at 07:00 PM AVividLight
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Well, Here is a script i made it may help u, put this script on ur money or whatever u want to pick up

using UnityEngine; using System.Collections;

public class PickUps : MonoBehaviour {

 public Transform Player;

 void Start()
     GameObject Plr;
     Plr = GameObject.Find("Write Ur Character Name Here");
     Player = Plr.transform;
 void Update()
     if (Score.Instance.ScorePointsLeft == 0)

 void PickUpWhileTouched()
     if (Vector3.Distance(transform.position, UrCharacterName.position) <= 1)
         Score.Instance.ScorePoints += 80;
         Score.Instance.ScorePointsLeft -= 80;


and put this script on ur player character

using UnityEngine; using System.Collections;

public class Score : MonoBehaviour {

 public GUIStyle mySkin;
 public static Score Instance;

 public Texture2D Win;
 public int ScorePoints = 0;
 public int ScorePointsLeft = 4000;

 void Awake ()
     Instance = this;
 void Update ()

 public void OnGUI()

 public void DisplayScore()

     GUI.Label(new Rect(10, 10, 100, 20), "Points: " + ScorePoints.ToString());
     GUI.Label(new Rect(10, 30, 300, 20), "Points: " + ScorePointsLeft.ToString());

 public void DisplayWin()
     if (ScorePointsLeft == 0)
         GUI.Label(new Rect(50, 50, 1000, 500), Win);



and thats all,.... u should play with the script untile u get what u want,

more ▼

answered Jul 16, 2011 at 07:16 PM

Ziad gravatar image

1.3k 26 25 47

Hello there thanks Ziad for the code i really appreciate it! Im just wondering if it the score will cumulatively add in the gui text if for example i pick up 5 items?

Jul 16, 2011 at 07:35 PM JamesReubenGruta

When u pick up something the score increace by 80 as i wrote in the script :) and add me if u need more info ziad_khalid@yahoo.com

Jul 16, 2011 at 07:38 PM Ziad

I got the logic thanks! but i jUSt tried and theres an error saying "Assets/zscripts universal/Pickup.cs(18,9): error CS0103: The name `Score' does not exist in the current context " do you encounter that error? Ill add you up later my friend in Yahoo messenger, i just have trouble logging in my account.

Jul 16, 2011 at 07:43 PM JamesReubenGruta

U Should name the first script as (PickUps) in ur project tap and the second as (Score) and that should fix the problem

Jul 16, 2011 at 07:46 PM Ziad

and don't forget to name it in the scripts too

Jul 16, 2011 at 07:48 PM Ziad
(comments are locked)
10|3000 characters needed characters left

First script as pickups is required in your project. I always use such script in my thesis writing management tools.

more ▼

answered Apr 12, 2012 at 03:16 PM

franksmith36 gravatar image


(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Jul 16, 2011 at 06:38 PM

Seen: 2183 times

Last Updated: Apr 12, 2012 at 03:16 PM