- Home /
click button and not show again
i want to create some script when score is greater then 100(>100) button shown, and when i click that button its not set active again, but when score decrease 100 (<100) and increase 100(>100) button show again , i don't want that i want when score greater than 100 button shown and when i click button not set active again, after that when score decrease to 100 and increase again button not set active
public GameObject object1;
if (Scores > 10) {
object1.SetActive (true);
}
public void whenclickbutton(){
object1.SetActive (false);
}
Answer by TomZe · Jun 25, 2018 at 09:36 PM
using System; using System.Collections; using System.Collections.Generic; using UnityEngine;
public class ButtonController : MonoBehaviour {
private bool Used ;
// import Scores var
void Start () {
Used = false;
}
void Update () {
if(Scores > 100 && !Used)
{
this.gameobject.setActive(true);
Used = true;
}
}
public void whenclickbutton() {
this.gameobject.setActive(false);
}
}
your Question is hard to understand pls use google translate next time . Add this script to your button and link the OnClick() event to the whenclickbutton() method.
Your answer
Follow this Question
Related Questions
Change sprite images on button click 0 Answers
Only want to detect button click event 1 Answer
SetActive Button from another scene isn't working in build 0 Answers
gui.button down 2 Answers