#button onclick scene change

1 messages · Page 1 of 1 (latest)

modest musk
#

i made a thread

quartz yew
#

Hi Thanks

modest musk
#

do You know how to attach a function to a button

quartz yew
#

No currently not

modest musk
#

on the bottom of the button component is there an "On Click" Section?

quartz yew
#

Yes its empty

modest musk
#

click the plus sign

quartz yew
#

Yes

modest musk
#

Select a component with the desired function

#

In this case

#

you have to create a component which has the scene changing function

quartz yew
#

Yeah uhm, i'm currently only working on the mainpage

modest musk
#

Can you create a test scene

quartz yew
#

wait wait

#

I have created an image background, but its in the front, how to put it in the back?

modest musk
#

change the hierarchy

quartz yew
#

got it

#

lol

modest musk
#

does the button work

quartz yew
#

how to create a test scene?

modest musk
#

right click assets folder

#

create

quartz yew
#

and btw, i need the button to work on touch

modest musk
#

scene

modest musk
#

Do you know how to create c# components

quartz yew
#

right click and create and c#?

modest musk
#

yes

#

add a function to that component

#

which changes the scene

#

You can do that by SceneManager.LoadScene("Scene Name");

quartz yew
#

Alright give me 2 min

#

Wait

#

@modest musk

modest musk
#

what

quartz yew
#

Do I need to create different scenes for like mainpage, options and the game scene?

modest musk
#

Depend

#

s

#

for game scene you have to

quartz yew
#

So I want to do a 2D Game for android

modest musk
#

for options if you want to make an overlay to the original scene you dont have to

quartz yew
#

So I can let everything in one scene?

modest musk
#

If you reaaally want to then yes

#

but its impractical

quartz yew
#

what to you recommend

modest musk
#

make a scene

quartz yew
#

also different scenes for each like options etc.

modest musk
#

If you want to overlay the settings then you have to make option into a prefab

#

You cannot separate a pause menu into a scene because loading a scene will cause already existing objects to be destroyed(You can avoid this by using something like DontDestroyOnLoad but I dont recommend this)