- Home /
Trying to make a Point system that references a Prefab.
Now i am very new to Unity, & what i am trying to do is make a point system and what i want it to do is when i click on an random generated prefab object it adds a point. Now since im not using a game controller or anything like that, i have no idea how to do this. Here is what i got.
using UnityEngine;
using System.Collections;
public class DestroyOnTouch : MonoBehaviour {
int myScore = 0;
public GUIText scoreText;
public void OnMouseDown () {//Work with touch
Destroy(gameObject);
myScore = myScore + 1;
}
public void OnDestroy () {
scoreText.text = "Score: " + myScore;
}
}
Im just looking for someone maybe to paste an example or link me a site that has information on this.
Answer by Seneral · Oct 06, 2014 at 11:54 AM
It seems you want to attach this script to the prefab, right? Then you have to reference to another script storing the values, as these values will be destroyed with the gameobject
Your answer
Follow this Question
Related Questions
GameObject clones won't add a point. 0 Answers
Multiple Cars not working 1 Answer
How can I make the script to play with the mouse? 0 Answers
Distribute terrain in zones 3 Answers
OnMouseEnter/Exit problem 2 Answers