Levelbuttons not refreshing stars

Help, support and information for our Game Framework Unity Asset.
If posting about the assets in the extras bundle then please use the appropriate forum.
Post Reply
tenfiddy
Posts: 24
Joined: Wed Jul 24, 2019 9:02 pm

Levelbuttons not refreshing stars

Post by tenfiddy » Sat Aug 10, 2019 7:20 pm

I am having a problem with the Levelbuttons. The correct number of stars appear in the gameover, but do not appear in the levelbuttons menu. But it is there...because when i click and release on the next level - I see the star light up and I am able to go to the next scene. Why is this not updating? And how can I make it update.

I am using the levelbuttons in the same scene as the gameover (Its in VR) ... I am sending the coins via a playmaker FSM . .. using the "set level coins". I have also tried "change level coins".

Here is a screenshot.

http://www.duhz.com/wp-content/uploads/ ... roblem.png

What I am trying to do. In the game...you throw the cigarette into a bucket of water. Player is trying to get all three stars. Miss and you get no stars. Hit the water with stars lit and "win" the one you hit. So I have script that figures out how many stars you should get and sets the proper amount of coins. The coin value is set 2 seconds before I call the gameover. The info is correct in playerprefs. The level setup is on automatic and I have tried from resources with the same problems.

And a short video...
https://youtu.be/QGJ86JWXtyE


Can you help?

tenfiddy
Posts: 24
Joined: Wed Jul 24, 2019 9:02 pm

Re: Levelbuttons not refreshing stars

Post by tenfiddy » Sun Aug 11, 2019 10:24 pm

So I think I got it working. Apparently I cannot put the _SceneScope or LevelButtons in a prefab and they both have to be in the root of the scene...hmm. That just kind of stinks because I had everything working in a prefab and I could just pull the entire thing over. The game I am making will have almost 100 scenes. So prefabs would be best.

Is there a way to get around this? To change the path?

mahewitt
Site Admin
Posts: 273
Joined: Thu May 05, 2016 8:06 pm

Re: Levelbuttons not refreshing stars

Post by mahewitt » Sat Aug 17, 2019 9:15 pm

Hi. Sorry about the slow response.

Taking a look through the code it looks like it could be because the levelbutton component isn't reacting to certain state changes (such as number of stars won.

As a test can you try adding the following code into FlipWebApps\GameFramework\Scripts\GameStructure\Levels\Components\LevelButton.cs

public void Update() {
SetupDisplay();
}

Not ideal, but it should hopefully provide a workaround until I can get event based notification in place.

Also, it should be fine to put _SceneScope and LevelButtons into prefabs and not have then in the root. Let me know if there is other problematic behaviour that this is causing.

Regards,
Mark

tenfiddy
Posts: 24
Joined: Wed Jul 24, 2019 9:02 pm

Re: Levelbuttons not refreshing stars

Post by tenfiddy » Fri Aug 23, 2019 10:56 am

That didn't quite work. It does refresh the stars but fails to play the animation to open the next level. So, the next level appears locked but can be clicked. (Because its really opened but just not refreshing / triggering...) So, half fixed.

If I go back to the Lobby / Menu ... then the animation appears. But I have to go to another scene.

Any idea how to get the entire thing working? Thanks
Last edited by tenfiddy on Sat Aug 24, 2019 11:08 pm, edited 1 time in total.

tenfiddy
Posts: 24
Joined: Wed Jul 24, 2019 9:02 pm

Re: Levelbuttons not refreshing stars

Post by tenfiddy » Sun Aug 25, 2019 11:39 am

I think I fixed it...

OK, so I remind everyone that I am doing this in VR, and I want all of the menu systems in my game scene without having to leave to another scene. All of my menus start the scene as inactive.

I deactivate the LevelButtons in the scene and activate them when I want to show the menu. But, doing this does not refresh the stars or show the unlock animation. The fix was simple (but I overlooked /hit my head against the wall for weeks)

SOLUTION: On the LevelButtons gameobject, simply go to the Buttons gameobject that is a child. And...in the inspector, deactivate it. Then when the LevelButtons are activated, the Buttons are still inactive. Now have a script on the LevelButtons activate the Buttons gameobject after a tiny wait to get the updated info. (I use .1 sec).

And it works. Holy cow. Now all my menus are in a single prefab and I can have a billion puzzle levels -haha

Note- if you call the method SetupDisplay() - you will skip the animation and not show the next level as being unlocked.

mahewitt
Site Admin
Posts: 273
Joined: Thu May 05, 2016 8:06 pm

Re: Levelbuttons not refreshing stars

Post by mahewitt » Tue Aug 27, 2019 7:01 pm

Glad you found a workaround. I have added a note to look into this and get a proper fix in place.

Post Reply