Page 1 of 1

Custom World Buttons - Conditions

Posted: Thu Sep 05, 2019 11:02 am
by tenfiddy
I want to be able to have more information appear on the world buttons, but I can't seem to get the information to populate by making changes to the prefab. The CreateWorldButton script seems to be assigning the World/Scene to load. And I want to assign that myself.

If I want to be able to identify the buttons as World_1 and such so I can use conditional statements and then use "Numbered" to get the condition. When I use numbered, now, the number is the same for each button, thus giving the same results.

And I want to be able to Conditionally show the stars won in a World on the world button. I think the condition action script will work by allowing me to activate a child gameobject on the button, but I can't find a ShowWorldStars or similar.

I have also tried setting the conditional action to from loop, and put it in the WorldButton prefab, but it doesn't work. (Wrror - When using a GameItemContext reference mode of FromLoop ensure that it is placed within a looping scope.
Gameobject: GameConditionGameItemUnlocked)

Can you help? I am still on this quest of wanting the Stars won to be scene in the world buttons. Not just the current selected world.

Re: Custom World Buttons - Conditions

Posted: Sat Sep 07, 2019 7:28 am
by mahewitt

Can you try posting a screenshot so I can see the heirarchy of the world buttons.

For the below it might be from loop that you need, however you need something to set this context. If the buttons are being created automatically with the CreateWorldButtons component then this should be set.

I added a componet ShowWorldStars if you want to test it. Place on Text Component and use {0} Total Stars {1} Won Stars. You will need to add / replace the following (backup first): ... ldStars.cs ... rs.cs.meta ... l/World.cs

Re: Custom World Buttons - Conditions

Posted: Sat Sep 07, 2019 1:42 pm
by tenfiddy

I cannot get the conditional statement to work on a "from loop" when using the loop in the game item. See error in screenshot.

And here is the heirarchy Am I putting something in the wrong place?


UPDATE: Manual Button Creation --- Almost Works. Conditions and all the new Game Items work.

Auto - nothing. The loop scope error continues.

Auto is easier, but if I have to...manual is fine.


But, unlocking the worlds does not work. I have tried to unlock with the UnlockWorldButton... but the dialog pops up and I would don't want that in VR, And after I unlock the level with the UnlockWorldButton it becomes inactive. Removing the scripts makes the button function again.

I want to unlock the worlds with the Total Stars earned through the entire game. I want to set the worlds like (World 2 -20 Stars, World 3 - 40 Stars, World 4 - 60 Stars) But not have the stars deduct from the total stars (no coins) So if the player has 40 total stars - World 3 would open. I am using, at the moment, the coin total to represent the total game stars won. But, I don't want to "pay" for the new Worlds, just open them when I get past a certain amount of Total Game Stars Won.

I hope this is the last hurdle. Thank you for your help.

Re: Custom World Buttons - Conditions

Posted: Sun Sep 08, 2019 8:05 am
by mahewitt
Can you try with the update in this file: ... Context.cs

My suspicion is that the component is trying to access this in Update or something but the 'FromLoop' reference is only valid on initialisation.

As a second option you could try 'Reference' mode and drag the World Button component into the ReferencedContext field, although I hope the above fixes the problem.

Re: Custom World Buttons - Conditions

Posted: Sun Sep 08, 2019 8:16 am
by mahewitt
Did a further test on this. The code change doesn't seem to pick up all cases, but teh second 'Reference' instead of 'FromLoop' mode seemed to fare better..

Re: Custom World Buttons - Conditions

Posted: Sun Sep 08, 2019 2:13 pm
by tenfiddy
I couldn't get the conditionals to work with the "Reference"... I can't grab the resource "value to unlock". Not sure if I need to set the conditionals to look at "from loop" or "reference"...

However, manually, everything looks promising. I have the unlock value set on each of the buttons in a conditional. I am using the player coins to represent the total number of stars won in the game. I am testing out the ability to perform multiple

So now my "problem" is when the new world is opened the player may not see the animation on screen. So I am trying to send a message or something to my player to alert them that a new world is opened. I can probably do it thru a Playmaker FSM just by tracking the player coins. I am experimenting.

But I am 85% pleased -lol