playMaker

Author Topic: [Solved] Keeping UI & another object on all scenes  (Read 2896 times)

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
[Solved] Keeping UI & another object on all scenes
« on: December 05, 2018, 10:23:16 PM »
Hi !

I made a casual game with 20 levels. 20 scenes.
I created UI only for one scene so far. Also UI , Camera & another GameManager (with lot of FSM) should be common for all scenes.

I made prefab of both UI, Camera & game Manager and put on all other scenes. it not worked. It gave so much "missing target" error. (GameManager has an FSM to enable * disable UI screen)

Ya ! Entire project ruined  >:( >:( >:( >:( . Now I loaded backup project. How can I put the UI, Camera & Game Manager to all other scenes?

Thanks
« Last Edit: December 07, 2018, 06:47:35 AM by heavygunner »

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Keeping UI & another object on all scenes
« Reply #1 on: December 06, 2018, 05:05:27 AM »
However, Well, I tried Don'tDestroyOnLoad. But, I didn't made it.
However, I m gonna redesign 20 levels again (won't take more than an hour) with new UI.

But, still looking for easiest solution

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Keeping UI & another object on all scenes
« Reply #2 on: December 06, 2018, 06:31:59 AM »
Hi,

 you have likely hardcoded references of gameobjects so when you move scenes, it looses the references.

make one scene for your UI and load that scene additively, then create a system so that it can communicate without hard reference but instead find gameobjects by tag or within a look up list available on each scene.

Bye,

 Jean

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: Keeping UI & another object on all scenes
« Reply #3 on: December 06, 2018, 01:42:47 PM »
I don't know if it's bad practice, but things that will be used in all scenes you could put under one prefab, references inside the same prefab should work.
I like it mostly because rolldown menus are way more convenient when sending and getting variables between objects.

Something I'm curious about is how Unity works if you do a 'find game object' on the first frame when the game startup is there a chance the object hasn't been created in the scene yet? Or do Unity create all objects, then starts running through scripts/components?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Keeping UI & another object on all scenes
« Reply #4 on: December 06, 2018, 04:26:10 PM »
Hi.

Load scene additive would be a good way to go like jean suggested.

Here's a tutorial about load scene async additive :


heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Keeping UI & another object on all scenes
« Reply #5 on: December 06, 2018, 10:29:50 PM »
Hi.

Load scene additive would be a good way to go like jean suggested.

Here's a tutorial about load scene async additive :

Hi !

Thank you :)
It worked.

I added DontDestroyOnLoad to Gamemanager & other necessary objects.

But, I have a Restart Function too. If Player lost, he can Restart level. Once Restarted Level, I see objects I added DontDestroyOnLoad doubled. Everything doubled. How can i fix it ?

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Keeping UI & another object on all scenes
« Reply #6 on: December 06, 2018, 10:36:07 PM »
Hi.

Load scene additive would be a good way to go like jean suggested.

Here's a tutorial about load scene async additive :

Hi !

Thank you :)
It worked.

I added DontDestroyOnLoad to Gamemanager & other necessary objects.

But, I have a Restart Function too. If Player lost, he can Restart level. Once Restarted Level, I see objects I added DontDestroyOnLoad doubled. Everything doubled. How can i fix it ?
I searched on Ecosystem for SINGLETONE . Got no results.
Found it after spelled correctly.

But, I don't know how to use it. Will try and update thread later
« Last Edit: December 06, 2018, 10:46:00 PM by heavygunner »

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Keeping UI & another object on all scenes
« Reply #7 on: December 07, 2018, 12:03:32 AM »
This method is working well. Even Singleton.
Unfortunately, The way I designed game is not compatible with these action. I have 20 Scenes, Each scenes had different Small maps. Each map has 10 Spawn points. So, FSM losing reference to spawn points upon restart & Load next levels.

So, Again I have to resume redesign the levels.

Thank you for everyone's input. learned important things today.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Keeping UI & another object on all scenes
« Reply #8 on: December 07, 2018, 01:23:35 AM »
Hi.
Maybe you can use arrays or array maker to place the spawn points in.

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Keeping UI & another object on all scenes
« Reply #9 on: December 07, 2018, 06:47:16 AM »
Oh !
I did manually :D
Will use this in future if wanted.

thank you very much