Author Topic: Clearing Confusion  (Read 5611 times)

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Clearing Confusion
« on: March 27, 2014, 11:47:59 PM »
I have two scenes: SCENE1, SCENE2.

Both scenes have their own UIRoot with a child Camera. The Camera's "Clear Flag" is set to "Depth Only" on both of them.

In the Editor:
When SCENE1 loads up, everything is fine. This is a main menu and I press a button to launch the game in SCENE2. When SCENE2 loads up, this is also fine. The new GUI is displayed.

If I build for MacOS (.app):
When SCENE1 loads up, everything is fine. This is a main menu and I press a button to launch the game in SCENE2. When SCENE2 loads up, I can see the SCENE2 GUI, but I can also still see the SCENE1 GUI.


Any thoughts?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Clearing Confusion
« Reply #1 on: March 28, 2014, 01:03:26 AM »
The first camera to draw must clear color/skybox, not just depth.

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Clearing Confusion
« Reply #2 on: March 28, 2014, 01:38:57 AM »
Ah.. thanks!

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Clearing Confusion
« Reply #3 on: March 28, 2014, 03:51:03 AM »
I'm curious about what's considered to be best practice.

Say I have 4 scenes:

Global, MainMenu, Loader, Game

Would it be recommended to set up the entire GUI in the Global scene (and make it persistent), and then turn parts off/on when needed - e.g. when loading into other scenes.

OR

Have a separate GUI (i.e. UIRoot and Camera) in each of the main scenes - MainMenu, Loader, Game.

I've always done it the first way - with a single GUI - but found it leads to more messy setup and code.

I was attemping to do things the second way this time around, but I'm now wondering if I hit these camera issues because you're just not supposed to do it that way?

Any advice appreciated.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Clearing Confusion
« Reply #4 on: March 28, 2014, 09:47:10 AM »
I personally prefer the separate GUI approach as it's cleaner -- each scene has only what it needs. If going with a single GUI, I'd advise making it into a prefab so that you can drag & drop it into any scene easily.

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Clearing Confusion
« Reply #5 on: March 28, 2014, 06:48:20 PM »
I personally prefer the separate GUI approach as it's cleaner -- each scene has only what it needs. If going with a single GUI, I'd advise making it into a prefab so that you can drag & drop it into any scene easily.

Okay - cool. That's what I'm doing in this new game. The single GUI approach isn't bad for a small game, but it was a nightmare in the last RPG...

Thanks again!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Clearing Confusion
« Reply #6 on: March 29, 2014, 06:04:27 AM »
If you have reusable elements such as an inventory window, just save it as a prefab. Pull in only the prefabs you need into your scene's UI.

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Clearing Confusion
« Reply #7 on: April 01, 2014, 03:45:42 AM »
Sorry - I have to go back to the original topic as I've just added another scene and I'm having issues again.

So...

I have three scenes: MainMenu, Loader, Game. MainMenu loads Loader which then loads Game.

Each has its own UI Root with Camera. Only the Game scene also has a second camera (Main Camera) for the game view - and this camera has a reduced viewport rectangle.

The clear flags are set as:

MainMenu: UI Root\Camera (clears Solid Color)
Loader: UI Root\Camera (clears Solid Color)
Game: UI Root\Camera (clears Depth Only), Main Camera (clears Solid Color)

When I run in the Editor - all good.

When I build and run a MacOS build, I get the following:

MainMenu looks fine.
Loader looks fine (can't see any "left-overs" from MainMenu).
Game GUI looks fine, but I can still see "left-over" GUI from the Loader in the area outside of the Main Camera viewport.

Any thoughts on how to properly set this up? And why it's only a problem in a build and not the Editor?

MAINMENU:

LOADER:

GAME:

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Clearing Confusion
« Reply #8 on: April 01, 2014, 09:54:22 AM »
If the main camera is set to clear only a part of the screen, then you will have a problem.