How to instantiate buttons for prefabs?

Options
In my project, I instantiate players as cubes. Also, I would like to instantiate a button when I instantiated a cube. (When I instantiate Player1, it will also instantiate a button only for Player1) When I click the button, a variable "Score" for the specific player will increase by 1. Player1's button will not affect to Player2's Score. How could I set the button? The script for button OnClick function is in the cube(Prefab). I have tried to put cube(Prefab) in the button and instantiate it. However it doesn't work.

Comments

  • Tobias
    Options
    When a networked object (with Photon View) gets instantiated, it can run scripts. Anything on the new object will run OnEnable() and Start() as usual but also OnPhotonInstantiate() gets called by PUN.

    Setup the button from one of those methods and add the reference accordingly.