#Help Newbie
1 messages Β· Page 1 of 1 (latest)
You're good. What part you can't figure out?
When I created the game I coded the whole logic on one script, this is the script of the unity the player controls. It's responsible for starting the game, spawning objects and when it dies it just resets its position
and cleans the stage
now I'm trying to setup a game manager to handle the game state changes
the first step I was trying was to create a start screen
I can create the start screen and it disappears when i click on play, changing the gamestate and everythin
but the whole game loads behind that screen
Okay makes sense so far
I've tried creating different scenes and load the gam scene only when the button is pressed, but it didnt do anything
the second scene started with it
I dont know if i should create a different scene for the start menu
for example
It is common to have separate scene for example Title scene and Main scene
What method did you use to load the scene and how it didn't work?
It's easy way too, because the scene will be reset if you load again, so you don't have to reset states yourself
first i created two scenes, one with the menu panel containing the background image, a simple playbutton and a menumanager. of the playbutton was pressed it calls SceneManager.LoadScene(1)
and within the build settings i had both scenes with the correct index
Uh huh Sounds about right
but when i click on play I can see the other scene being loaded on the background without me pressing the playbutton
Are you pressed Play button from the title scene but the other scene loaded?
So you were opening the scene 0, press play from Unity, and scene 1 loaded?
I click on play, scene0 and scene1 load, I press play and the scene1 is already loaded
Because that shouldn't happen, Can you share the script?
I click on play (being the playbutton to run the game(
sure
how's the best way? just copy and paste it here?
#854851968446365696 has section about Posting Code at the bottom
that's the "whole game" as one entity
this is the menumanager which was in a different scene
StartGame is the function called on pressing the playgame button within the start menu
Hmmm anywhere else is calling StartGame?
How does the GameManager look like?
the GameManager https://paste.ofcode.org/r8uXKfJrs6FbrqqVMbqfxN
Hmm it's weird. It should not load scene 1
Unless you were opening scene 1 before press play button from Unity
Were you editing both scene at the same time?
I don't think so
Can you still reproduce the issue?
how's the best way to do it?
Just take a video and drag into discord
ok
i'm just finding a way to record my screen π I have no idea how to do it on windows
π
Hmmm try Win+alt+R
thats the video but i got no audio there
Is it right? I can only see the code screen for some reason
Not the unity editor π’
oh it's not showing the screen
i got it
When you see your hierarchy view on the left
There is two scene open
Menu and Game
Try double-click your Menu scene from project view on the bottom
You'll see only one scene open
yes
Now you can try play button from that scene
but then the button within the menu panel doesnt work
It can be because the gamemanager is within scene1
Oh right. I think you won't need GameManagerOnOnGameStateChanged if you split scenes π
Because you'd just Load scene 0, when you want to return to title.
But it will be different story for in-game pause menu.
I see, so what I could do is just call the loadscene instead of changing the gamestate?
Yes, you can do that
Tip: You made your GameManager singleton but if you want it to live across scenes, you need to call this
Are you getting errors?
Are you in Play mode? π
yeap
here it is
it didnt show the color panel π
but it was just supposed to show that it should have changed the button appearance with hover
or click
Oh I think you're missing EventSystem in your scene π
Copy it from the Game scene?
You need EventSystem for UI events like mouse hover or click
yaaay
it works
adding the event system
made it work how it's supposed tro
thank you very much!
you saved a life today π
I guess we can close this thread then
thank you again
Alright! Glad it helped. Ask to channel if you have another issue!