#what do you mean only one MuonCounter?
1 messages · Page 1 of 1 (latest)
I'm confused, what are you asking?
How do I word that differently?
Is there a possibility that another MuonCounter exists when you load a new scene? So does the scene contain a MuonCounter?
there's only one muoncpunter, and that one only exist the the stage selection scenes
What is calling LoadData/SavaData and when?
And to be clear, is the issue that _amountMuons resets when you load a scene or what?
You should clarify this ^
I don't know if it resets or jsut staying like the same number
You don't know?
I said I don't know if it resests or just staying the same 0 number
You said:
issue where a counter is not persisting across scenes
How do you know that issue exists if you don't check the value?
Does it reset when you load a new scene or some other time specifically?
And what do you mean by "counter" - is it MuonCounter, Counter, or the variable itself?
Highly likely your Singleton isn't proper (missing guards for instance) and simply creating new instances
the Muoncounter which is the one that counts how many muon objects you have touched from other scenes
and while Counter is the one that is in the gameplay scenes and even counts how many coincs you have collected 100 each
The Singleton pattern: https://unity.huh.how/references/singletons
I'm asking what you meant with "counter" in that specific question you asked on stackexchange
What is not persisting
I don't know, but it's not supposed to reset back to zero
When does it become zero again?
i lireally explained it here that the counter script is the one in counts how many coincs you have collected in the gameplay scenes
it's not supposed to become zero agian
When does it become zero again?
Probably because your scene has a GoalVictory instance which calls Counter.SavaData in Start
Which changes MuonCounter.instance._amountMuons
So is this about Counter or MuonCounter? 🤦♂️
I still don't know which one you are talking about. What is resetting
Both, since that the Counter have the savedata and loaddata, and muoncounter is the one that counts how many muon objects you have touched
also, nothing is supposed ot reset of the muoncounter about how many of them you have touched
After you change scenes, type t:counter and then t:muoncounter in the hierarchy window's search to see how many of those you have in the scene(s)
From what I see it still does sound like you have multiple instances of either one, while there should always be just one
there are 3 muon objects in each gameplay scene,
i was told i supposed to also have instance = this in the counter script
Except cs MuonCounter.Instance._amountMuons = PlayerPrefs.GetInt("AmountMuons");
I'm not asking about muon objects
what about it? i was told i am supposed to write it there
That could be setting it to zero
I see you calling Counter.Instance.LoadData from GoalVictory.Start
This sets MuonCounter.Instance._allMuons to whatever you saved in PlayerPrefs
And I don't see you saving anything to playerprefs
Okay I see you calling SavaData from GoalVictory
yeah
Search for counter, muoncounter and goalvictory instances in your scene after the scene changes/when the bug happens
how can i search for counter, muoncounter and hoalvictory instances in my scene? in the gameplay scene?
Did you read this..?
You can search by type with t:typename
See how you have multiple muoncounters in the scene?
Which is why I asked this #1267554070038712341 message
Start by implementing the singleton pattern properly: #1267554070038712341 message
hmm... in the muoncounter?
Sure
ok
well it seems to be working, almost, because missing (TMP_Text)
and since the ui text is in canvas
but it was a good progress through?