Home > Software engineering >  Unity, attached a script onto button(prefab) but does not show public function
Unity, attached a script onto button(prefab) but does not show public function

Time:12-14

As you can see the picture below, I already attached a "DeleteQuizDetailRow" script onto a button (On CLick() event), but there is no public function in the script

public class DeleteQuizDetailRow : MonoBehaviour
{
    public void test()
    {
        Debug.Log("test");
    }
}

enter image description here

CodePudding user response:

You need to attach the script in the gameobject, then drag and drop the gameobject to the slot, do not drag and drop the script directly from your files to the slot

CodePudding user response:

I can help you with that it's easy to do. you dragged the script from your project view to the inspector view streat to the button . Instead do this

  1. create an empty GameObject in your Hierarchy call it something like > ButtonsManager
  2. Drag and drop your script DeleteQuizDetailRow inside the empty gameObject
  3. Now Select this new ButtonsManager gameObject and drag , drop it in the runtime button slot this should work fine I'll link some useful videos for you my friend Unity tutorial playlist
  • Related