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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How to make button that will work on every clone of specific prefab

Discussion in 'UGUI & TextMesh Pro' started by Loud_Lasagna, Dec 16, 2019.

  1. Loud_Lasagna

    Loud_Lasagna

    Joined:
    Oct 24, 2019
    Posts:
    26
    I have random amount of chests in my scene and script for them is working fine but i want to use UI button to open the chest and simply putting chest prefab in "On Click()" isn't working and i need a little help with that. How i can make the button work on every chest prefab in scene automatically?
     
  2. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,835
    Are you saying that you have a button inside the prefab that you need to connect to some external object, or that you have an external button that needs to detect which copy of the prefab is in front of you?
     
    Loud_Lasagna likes this.
  3. Loud_Lasagna

    Loud_Lasagna

    Joined:
    Oct 24, 2019
    Posts:
    26
    External button that needs to detect which copy of prefab is in front of me
     
  4. Loud_Lasagna

    Loud_Lasagna

    Joined:
    Oct 24, 2019
    Posts:
    26
    thank you for writing "button inside prefab", this is working exactly the way i need it