Quantcast
Channel: Questions in topic: "points-counter"
Viewing all articles
Browse latest Browse all 51

Points-Counter Problem

$
0
0
Hello guys. So I have in my scene 3 canvas. Each canvas has 3 buttons. Each button can give you 0 points, x3 points, x5 points and x10. When you click an object in the scene the canvas gets enabled.Here is the script using UnityEngine; using UnityEngine.UI; using System.Collections; public class ButtonOnClickActive : MonoBehaviour { public GameObject canvas; private bool clicked; void OnMouseOver() { if(Input.GetMouseButtonDown(0) && !clicked) { canvas.SetActive(true); clicked = true ; GetComponent().material.color = Color.red; } } } And here is the script for points it is the same for each one just with changed numbers(x3,x5,x10) using UnityEngine; using System.Collections; using UnityEngine.UI; public class x3 : MonoBehaviour { public Text scoreText; public int point; // Use this for initialization void Start () { } // Update is called once per frame void Update () { scoreText.text = point + " x3"; if (Input.GetMouseButtonDown(0)) { point++; } } } Every button has a script accordingly to what points it is going to give. The thing is that when you click the objects, points are added automaticaly adn when you click a button more points are added for every button. Can anyone help me out? Cheers

Viewing all articles
Browse latest Browse all 51

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>