playMaker

Author Topic: ui button on click event from another object to a prefab[SOLVED]  (Read 924 times)

colpolstudios

  • Sr. Member
  • ****
  • Posts: 365
ui button on click event from another object to a prefab[SOLVED]
« on: September 10, 2022, 04:43:01 PM »
I have two objects that need to set the target UI button on a prefab.

Is there another way to do this rather than dragging the UI button into the required field?

Both of the objects are outside of the initial prefab, but the user needs to be able to click on the UI button that's within the prefab.

At present, I can drag the UI button into the field, but the prefab will be able to move between scenes hence my question.
« Last Edit: September 11, 2022, 04:35:38 PM by colpolstudios »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: ui button on click event from another object to a prefab
« Reply #1 on: September 11, 2022, 04:49:21 AM »
Hi.
You can have a global gameobject variable with a "Data" fsm on that fsms you can then set variables (game objects in this case) where you can set your buttons.

now you can access them easily from a prefab (Get fsm Game Object an set to the variable that has the  ui button on click action.

The global gameobject you can set one for each scene and use Get Owner to place it to the gameobject variable.

this is useful for scene specific things.

You can Also make the "Data" game object persist thru all scenes by using "Dont Destroy On Load" action.