playMaker

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

heavygunner

  • Full Member
  • ***
  • Posts: 114
    • View Profile
[Solved] Keeping UI & another object on all scenes
« on: December 05, 2018, 08: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, 04:47:35 AM by heavygunner »

heavygunner

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: Keeping UI & another object on all scenes
« Reply #1 on: December 06, 2018, 03: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: 13638
  • Official Playmaker Support
    • View Profile
Re: Keeping UI & another object on all scenes
« Reply #2 on: December 06, 2018, 04: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
  • Junior Playmaker
  • *
  • Posts: 94
    • View Profile
Re: Keeping UI & another object on all scenes
« Reply #3 on: December 06, 2018, 11:42:47 AM »
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: 3664
    • View Profile
    • jinxtergames
Re: Keeping UI & another object on all scenes
« Reply #4 on: December 06, 2018, 02: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

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: Keeping UI & another object on all scenes
« Reply #5 on: December 06, 2018, 08: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

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: Keeping UI & another object on all scenes
« Reply #6 on: December 06, 2018, 08: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, 08:46:00 PM by heavygunner »

heavygunner

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: Keeping UI & another object on all scenes
« Reply #7 on: December 06, 2018, 10:03:32 PM »
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: 3664
    • View Profile
    • jinxtergames
Re: Keeping UI & another object on all scenes
« Reply #8 on: December 06, 2018, 11:23:35 PM »
Hi.
Maybe you can use arrays or array maker to place the spawn points in.

heavygunner

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

thank you very much