x


GuiText Score On Mouse Click

Hello, Im trying to make a scoring system in two parts, one that is attached to a GUIText and another that is attached to an object to be clicked in order to add up points.

This is what I currently have on the GUIText

var Counter : int = 0;

function onGUI(){
    guiText.text = "Score: "+CountingCode.score;
}

and this is what is on the object to be clicked to get points

CountingCode.js

static var Counter : int = 0;

function OnMouseDown(){
      Counter+=10;
}

When I click the afformentioned object with these scripts active nothing happens. Can someone please show me what is wrong?

more ▼

asked May 10 '12 at 06:42 PM

Alayna gravatar image

Alayna
219 8 11 15

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Put a Debug statement in OnMouseDown() - I'd guess that it isn't getting called at all.

Make sure that the object you are clicking on:

  1. has the script CountingCode.js attached to it (which I presume is the case based on your comment)
  2. is a GUI Element or has an active collider attached to it.

Hope it helps!

more ▼

answered May 10 '12 at 09:53 PM

sumiguchi gravatar image

sumiguchi
20 2

(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

By RSS:

Answers

Answers and Comments

Topics:

x5088
x1961
x985
x313
x101

asked: May 10 '12 at 06:42 PM

Seen: 858 times

Last Updated: May 10 '12 at 09:56 PM