Reputation: 25
Trying to write a script that's on several different objects where on mouseclick, 1 is added to a defined variable which then prints out. Currently when I click the objects, 1 is always printed.
#pragma strict
import UnityEngine.UI;
var theImage:UnityEngine.UI.Image;
var theSprite:Sprite; //The image you want to drag in the inspector
private var clickCount = 0;
function OnMouseDown () {
theImage.sprite = theSprite;
clickCount++;
Debug.Log(clickCount);
}
Here's my script. It also changes a GUI sprite. Seems like an easy fix, not sure where I've gone wrong.
Upvotes: 2
Views: 90