Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

2D Tapping game popup problem

Discussion in '2D' started by VenatusGullebulle, Dec 26, 2021.

  1. VenatusGullebulle

    VenatusGullebulle

    Joined:
    Dec 26, 2021
    Posts:
    3
    Hello! I'm trying to create a 2D tapping reflex type of game but got stuck when trying to generate a new circle to click on. So i have this button object with a picture of a circle in it which you can press and then a new button circle object is supposed to generate. The code I've written looks like this and a new button object is created but it gets created outside of the canvas and when you drag it into view it's just a transparent object which nothing happens with. What i want to do is create a new circle within a marked area inside my canvas everytime someone clicks on the object. Any help will do!

    public class ButtonFunction : MonoBehaviour
    {
    public void SpawnCircle()
    {
    GameObject circleAppearing = GameObject.Find("ButtonsToClick");
    Instantiate(circleAppearing);
    Destroy(circleAppearing);
    }
    }
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,171