So far, I’ve got this for a button:
var AcceptInput : boolean = true;
private static var score : int = 0;
var guiScore : GUIText;
function Start ()
{
guiScore.text = "Score: 0";
}
function OnMouseDown () {
if(AcceptInput)
{
AcceptInput = false;
}
GameObject.Find("Obejct").GetComponent(Script).enabled = true;
Debug.Log("Clicked");
score += 1;
guiScore.text = "Score: " + score;
}
function OnMouseUp () {
AcceptInput = true;
GameObject.Find("Object").GetComponent(Script).enabled = false;
}
And the script I want it to be activated:
var diamond : Sprite;
var circle : Sprite;
var triangle : Sprite;
var square : Sprite;
private var number : int;
private var spriteRenderer : SpriteRenderer;
function OnEnable() {
spriteRenderer = gameObject.GetComponent(SpriteRenderer);
number = Random.Range(1,5);
if(number == 1) {
spriteRenderer.sprite = diamond;
}
else if(number == 2) {
spriteRenderer.sprite = circle;
}
else if (number == 3) {
spriteRenderer.sprite = triangle;
}
else {
spriteRenderer.sprite = square;
}
}
How can i make it like if the sprite is diamond, add a score and play a sound and if not correct, start the score all over again?
Anyone have any ideas? Any help would be much appreciated! Thank You!