playMaker

Author Topic: How to switch between two scenes/tabs without losing progress?  (Read 1293 times)

chisahana

  • Playmaker Newbie
  • *
  • Posts: 4
How to switch between two scenes/tabs without losing progress?
« on: September 21, 2020, 04:17:18 AM »
Hi!,

I'm new to Unity and Playmaker, and don't have any coding knowledge, but I've managed to work around problems besides this one:

The game I'm working on is an idle game that has two different tabs that the player can switch between.
Tab 1 is like a shop with items that are continually selling which the player can collect coins from after a period of time.
Tab 2 is a dress-up type game which I will eventually connect to the shop.

I want to be able to switch between these 2 tabs using menu buttons at the bottom of the screen, but I'm not sure what Actions would be appropriate to do this. Here are some methods I have tried which did not work for me:

1. Having both tabs in separate scenes and using the load scene action. This resulted in loss of progress as the game would reset when the scenes changed.
2. Having both tabs in one scene and using activate and deactivate on the respective objects. This resulted in loss of progress as well, and some elements that should not have been active are activated once I switch back to their tab.
3. Having both tabs in one scene and altering the visibility and canvas alphas. Visually this works, but by setting the alphas to 0, the objects are still there, so objects beneath it cannot be clicked.

I feel like there must be a simple solution that I'm missing since I'm new to this, and this type of switching isn't a new mechanic. I've looked around for tutorials but I couldn't find anything. Any help would be greatly appreciated!

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: How to switch between two scenes/tabs without losing progress?
« Reply #1 on: September 21, 2020, 04:41:44 AM »
I'd go with 3rd method and de-activate second tab panel entirely

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to switch between two scenes/tabs without losing progress?
« Reply #2 on: September 21, 2020, 05:32:45 AM »
Hi.
Yes 3rd method but instead of changing alpha have each tap parented in a panel.
Then Enable / Disable the panels.

A side note : ui components have a checkbox called raycast target :) it can disable enable detection

chisahana

  • Playmaker Newbie
  • *
  • Posts: 4
Re: How to switch between two scenes/tabs without losing progress?
« Reply #3 on: September 21, 2020, 06:01:25 AM »
Hi.
Yes 3rd method but instead of changing alpha have each tap parented in a panel.
Then Enable / Disable the panels.

A side note : ui components have a checkbox called raycast target :) it can disable enable detection

OMG the raycast target made the third method work. Thank you so much!

Just for more info, will Enabling / Disabling the panels cause the FSM to stop? When I use the "Activate Game Object" Action it causes the FSMs in my panels to stop, so the timer progress doesn't continue which isn't my intention.

Thanks again!

chisahana

  • Playmaker Newbie
  • *
  • Posts: 4
Re: How to switch between two scenes/tabs without losing progress?
« Reply #4 on: September 21, 2020, 06:04:56 AM »
I'd go with 3rd method and de-activate second tab panel entirely

Will de-activating the panel send the FSM back to the start state when it's activated again? I tried using the "Activate Game Object" Action and it sent the FSM back to the start state, even though I want to keep the FSM running but hide the visual elements. Is there any way around that?

Thanks so much for the reply!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to switch between two scenes/tabs without losing progress?
« Reply #5 on: September 21, 2020, 10:07:27 AM »
Hi.
Have the fsm on a parent object.
and on the actions, target what you need, instead of use owner.

chisahana

  • Playmaker Newbie
  • *
  • Posts: 4
Re: How to switch between two scenes/tabs without losing progress?
« Reply #6 on: September 22, 2020, 12:20:27 AM »
Hi.
Have the fsm on a parent object.
and on the actions, target what you need, instead of use owner.

Ok! I will give this a try. Thank you so much  :)