#Heyo it s me again I fixed the previous

1 messages · Page 1 of 1 (latest)

hazy niche
#

Here

restive roost
#

Basically part of UI is missing because I disabled it because it’s on DontDestroyOnLoad and now I dunno how to enable it because my game manager is also on DontDestroyOnLoad

hazy niche
#

which UI

#

and in the future please use something like OBS or ShareX to record your screen

restive roost
#

I will

restive roost
# hazy niche which UI

Level 1 sign and the egg and the counter were all loaded into main menu and level select

hazy niche
#

oh i see

#

what starts your game?

#

like when you select the Level

#

what's called?

restive roost
#

the script?

hazy niche
#

yeah

restive roost
#

It's called BackToMenu script that another guy made

#

Because basically UI and menus are supposed to be their job and gameplay and level design is supposed to be mine

hazy niche
#

okay, can you please show me that script..?

#

why do you need to set the text to DDOL though

restive roost
#

Wdym DDOL?

hazy niche
#

Dont Destroy On Load

restive roost
#

I think because I was trying to fix another issue earlier

hazy niche
#

i think I know the issue. your GameManager loses reference to the text

#

it's better if you dont make the text belong to the GameManager. Just put it in a script that's in the level itself

#

you already can get a reference to the coins easily because GameManager is a singleton

#

so you separate the counterText from GameManager, then you don't need it to be DDOL

#

then you dont need to disable or enable it

#

so in case you dont get what I just said. you declare another script that holds your counterText. you remove it from your GameManager.
This script, you put into a GameObject that's only in your Level. it doesn't need to be DDOL

#

this counterText script can get the coins variable from your GameManager

restive roost
#

Okay thank you will try it

#

To be honest I don't struggle writing code for the game play that much but when it comes to the menus 'nd stuff it just messes with my head

#

so "eggNum.text = " 0 / 12";" this line should be added to another script?

hazy niche
#

yes. your egg counter text should be handled by another script that's only in the game scene, and not DDOL

#

so you dont have to worry about it being shown outside the game

#

and your GameManager doesnt need to hold the reference to it

restive roost
#

Okay did it, now the counter and level text disappears like it needs to

#

But counter doesn't increase after I restart the level

#

I had that problem before

hazy niche
#

does that print?

#

what do you mean the counter doesnt increase

#

is it that the text doesnt update?

restive roost
#

Yeah it does, everything in code that adds coins works, it's the UI or UI script itself and I forgot how I solved it before

hazy niche
#

or that coins doesnt go up

restive roost
hazy niche
#

and it doesnt go 1/12?

restive roost
#

Nope, not once I restart it

hazy niche
#

the easiest way is to just set the text in Update

restive roost
#

But debug works for adding coins

hazy niche
#

the better way is to use events/delegates

#

how about you show your countertext script

#

i will have to go soon

#

but i think you could just update the text in Update?

restive roost
hazy niche
#

your GameManager is already a singleton..

#

do you not know what that means

restive roost
#

Not really

hazy niche
#

it means you can easily access it through its static property

#

like you have this public static GameManager Instance { get; private set; }

#

and you dont even know what it's for

#

you could just do eggNum.text = GameManager.Instance.coins.ToString() + " / 12";

#

you dont need public GameManager gameManager;

#

i suggest you actually learn what you just did

#

i have to go now