Hey. So I am trying to code a game for Android, and i have a lot of troubles, because i had big expectations, but i just don't know how to do it. I am beginner and I would love if you could help me. So. I want to code a game, that shows a button(or gameobject that looks like button), and when you touch it, it disappears and appear randomly on the screen - till user ends the game (I then want to do it with time, so if you wont press it until -idk- 2 secs, it's game over, but i think that is not that hard to code ). I know it sounds easily, but i have tried to run this game many times, but i dont know, how to do it. Could you please help me ?
I am having problem with literally everything. firstly i tried this game with UI button, but all I could do is just destroy that button after clicking.
you can disable the button and its image components, or the whole button gameobject to completely hide it. do that from separate script, since if you disable the gameobject, scripts wont run on that gameobject anymore.
try something like, attach this script to empty gameobject, then assign your button into that field, then in the button OnClick even, assign your empty gameobject with the script, and select the Hide method from that dropdown: Code (CSharp): using UnityEngine; public class HideButton : MonoBehaviour { // assign your button reference here public GameObject mybuttonGameObject; // this method is called from button click public void Hide() { // disable gameobject to hide it mybuttonGameObject.SetActive(false); // after 2seconds, show the button again Invoke("ShowButton", 2); } void ShowButton() { // TODO you could then randomize the position here mybuttonGameObject.SetActive(true); } }