Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Scene Visibility Tools - Info and Discussion Thread

Discussion in 'World Building' started by gabrielw_unity, Dec 5, 2018.

  1. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,179
    Also, are there any plans for streaming scenes to show up / hide automatically (in the hierarchy/vis list) when streaming, particularly when around / far away from the camera in-editor?

    This is killing me in developing streaming games in-editor.
     
  2. neil_devine

    neil_devine

    Unity Technologies

    Joined:
    Apr 8, 2018
    Posts:
    17
    @PiezPiedPy sorry for the late reply, I seem to have forum notification issues. You would have to do that yourself, with setting the HideFlags, and turning off the renderers. What are you trying to do ?
     
  3. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    727
    Hi! Just had a chat about this, seems like a good plan to add a preference for how SceneVis is saved (or not). Something like "Clear SceneVis data: (Never; Only when I close Unity; Whenever I close a scene)".

    Will look into when we can add this, thanks for bringing it up!
     
  4. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    727
    I don't think we would handle this ... though the SceneVis system might be involved ... I would ask in the Editor General section :)
     
  5. neil_devine

    neil_devine

    Unity Technologies

    Joined:
    Apr 8, 2018
    Posts:
    17
    Hey, in the mean time you could call SceneVisibilityManager.ShowAll at the appropriate times, or delete the SceneVisibilityState.asset at the root of your Library folder
     
  6. neil_devine

    neil_devine

    Unity Technologies

    Joined:
    Apr 8, 2018
    Posts:
    17
    Could you give some more details on your problem ?
     
  7. Adrien-TA

    Adrien-TA

    Joined:
    Jan 11, 2019
    Posts:
    7
    @gabrielw_unity Thanks for looking into that ! Those options seem to cover our needs, we will wait for them.
    @neil_devine I'm not confident in erasing Library stuff at runtime =D but the alternative of calling ShowAll on a callback like EditorSceneManager.sceneOpened sounds like a good idea, I will give it a try.
     
  8. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,179
    Sorry for the delay --

    So basically, when I am designing maps for a streaming world game (whether it is a 2d or 3d game), I generally have an area of the map that I am working in, but rather than working in one place at a time, I tend to work all over the map at once (using my plugin, Snapcam, to navigate me around the world instantaneously). Getting around the scene this quickly inherently means that I must show/hide/load/unload any distant scenes manually.


    The problem with this is that, whenever I instantly "snap" to a new position in the world so that I can edit the objects there, I have to manually load/unload various scenes / display any hidden objects for performance CONSTANTLY, with no way to ensure what I need to show/hide/load/unload will be taken care of as I arrive.
    Due to these performance issues that sometime crash the editor, I cannot simply use the editor to EDIT my streaming game -- To do this (at least for art), I am forced to use external tools like Blender or Houdini in very non-standard ways to modify my art due to Unity's editor-specific issues like floating point limitations or just general unwieldiness when I'm snapping around these large worlds.
    Ultimately, the area around the editor camera should automatically load new scenes and automatically hide and unload other far away areas (or turn them into imposters after a certain distance, so you can visualize the skyline).


    In general, I would probably want to specify a distance threshold from the camera where scene hierarchies (specified by a master scene) would either display imposters after I move a certain distance away, or be unloaded entirely. When I start back toward this position (within a given threshold) or when I suddenly move the camera there, I would want the scene to be reloaded so that it displays imposters/LODS as I approach it, and then becomes fully detailed after I reach a certain distance from its central origin (perhaps the first gameobject in the scene is the origin of that loaded scene?)

    Positioning in super large streaming worlds gets trickier as the units scale, but using in-editor tools to craft these large worlds gets even trickier (or impossible) with certain long-distance movements beyond a certain threshold. My worlds are getting bigger, and my goto tools are failing me.

    Perhaps handling floating origins in-editor (for visibility/loading purposes) might be an option? -- i.e. if my position is 100,000 km, then the Editor itself sees only a small bit of this at a time, locally around the world origin, which allows users like me who are authoring streaming worlds to use tools like ProBuilder as if they were close to the origin (despite them actually being crazy far away.) Unity would just compress the positioning in chunks of whatever size the user specifies so that these crazy-far-away scenes can be visualized/hidden/unloaded/reloaded and (most importantly) EDITED, whenever necessary.

    Ultimately, showing/hiding scenes/objects for me automatically as I zip around my world is what I want SceneVis to help me do, but the last time I checked, the Editor itself can't do even basic scene positioning when loading a scene (i.e. loading/unloading a scene into/from a specific position in the world). So SceneVis won't work for what I actually need it to do -- especially when it involves editing a scene that has a floating origin (like mentioned above). Unity as a whole assumes I'm just working on ONE single area/scene all the time. Unity assumes that area will never be far enough away from the origin for it to ever matter that using a tool like Probuilder (or other official Unity tools) to design my world at far away distances is actually impossible without the floating origin being recalculated periodically (when the position shifts to far away distances) and assumes I will just make my own tools (i.e. Reprogram Probuilder) for handling such use-cases. However, it is clear to me that these floating origin use-cases are becoming more and more common and I am struggling to keep up with the editor's own scene-management API throughout Unity's progression into a modern editor. MegaCity is a lot to digest, for example, but doesn't handle the floating origin visibility scenario.

    I know that visibility options and better hierarchy management is the purpose of SceneVis tools, but visibility is even more important with a streaming world -- especially one with a floating origin -- because one needs the tools to visualize it in-place and manage it even more carefully than a standard-fare portal-based / static world.



    My only options for this kind of visualization in Unity is to work on every single area of my game (i.e. using Probuilder) near the origin, never being able to fully visualize the connected world as it really is, OR always rely on third-party modeling programs like Houdini or Blender to see the meshes properly positioned and semi-connected (but with complicated visibility scene-loading setups in the modeler (that would be better-off programmed once in the game engine instead) with the inaccuracies of all the wrong materials/lighting due to it not being in-engine. Otherwise, we must duplicate work.
    So far, the only "solution" (to the in-game streaming at least) is the very "iffy" (and dated) (and poorly documented) World Streamer asset that can only do so much anyway when it, too, struggles with the editor's mandates on positioning/loading/visibility.
    In the end, all I really need is to show/hide/load/unload things at the proper moments, and display them in the correct places so I can visualize them (usually following some kind of square or hexagonal grid formation).
    This process seems so fundamental for a modern game engine, but I can't help but wonder why is process this is SO overlooked by third-party game engine development teams? -- Do I really need a separate game engine for the single mundane purpose of simply showing/hiding/unloading the things I need to show/hide/unload at a given moment just so I can EDIT the world?
    This is all distance-based visualization stuff that Unity should already do for me, especially as streaming games with streaming assets have been (and continue to be) the norm in the same games industry that aims for hyper-realistic realtime graphics. The heavier the graphics, the more burden it puts on the editor.

    This is killing me. :/

    I just want to be able to move around and work in the Editor freely and not have it die on me!

    Making games is tedious enough, but with the editor itself not being able to do its own job without my assistance... This gets unnerving to say the least... SceneVis should (inherently) be about helping to maintain both performance and flow (as should all parts of the Unity Editor!) But as far as I see it, when it comes to either performance OR flow, with editing streaming game worlds, Unity's editor doesn't have a clue about all the problems and headaches conjured up by the single issue of basic visibility in streaming world workflows, and developing tools willy-nilly to solve editor visibility without fully considering these issues is a recipe for disaster. I just want to use Unity's official tools to let me visualize / edit the materials/objects across my scenes (with usable performance!) wherever they may be, while being able to zip around my game world as I see fit.

    This really should not be too much to ask. Who knows which team is on it -- either way, you guys seriously still need to __work together__ to make a usable in-editor workflow for streaming game world visibility.



    TL;DR:

    If you don't have time to listen to my amazingly well-spelled-out frustrations, you probably should skip this anyway. lol This is mainly just for the Unity dev who asked me to clarify the problem, so I'm offering as much clarification / details as I feel is necessary to spell out the significant pains I am going through (while also offering potential solutions). This is, after all, a discussion thread. There's lots to discuss.

    :)

    And if you read this, thanks for taking the time! -- These kinds of workflows seriously need to be addressed. Games are only going to get larger. Unity will be so much better for it in the end.
     
  9. neil_devine

    neil_devine

    Unity Technologies

    Joined:
    Apr 8, 2018
    Posts:
    17
    Hi, thanks for the detailed response. I totally see your point with problems editing large streaming worlds, and how some tools do not perform as well when far from the origin. We have been improving these lately, but for the ones we may have missed, I encourage you to enter bug reports and post them in the WorldBuilding forum or send to me directly.

    SceneVis was not designed or intended for use for any kind of performance improvement or streaming visibility management. It was designed to help users hide away things getting in the way of editing other things.

    As for streaming management, admittedly it is very specific to each game, requirements can be vastly different. We provide the basic building blocks from which you can build your own tailored solution, but as you say there is a lot to discuss on this subject, I believe this merits its own thread in this forum.
     
  10. Esc_Maleficus

    Esc_Maleficus

    Joined:
    Jun 3, 2019
    Posts:
    1
    Quick question: I'm using "SceneVisibilityManager.HideAll" in a script to hide all objects in the Scene view.

    This works fine, except when I hit the Play button. If the game is running, and I click over onto the Scene tab - all of the hidden objects are now rendering, even though they are all marked hidden in the SceneVis.

    Clicking the Hide/Show eyeball in the object hierarchy has no effect as long as the game is running. If I shut the game down, then the settings are respected again and the objects will disappear as expected.

    Is this intentional?

    Is there a work around to get the behavior I'm looking for ( if I hide objects in the scene view, they stay hidden regardless of whether or not I'm playing the game ).

    Thank you!
     
  11. neil_devine

    neil_devine

    Unity Technologies

    Joined:
    Apr 8, 2018
    Posts:
    17
    There is a limitation whereby if your scene has never been saved (no id associated to it), switching to playmode will render all objects visible. This should not happen if you have saved your scene at least once.
     
  12. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    727
    Hey @awesomedata ! Would you be okay if I move this discussion to a separate thread? It's larger than just SceneVis, and I'd like to avoid this thread losing it's focus, and also avoid your thoughts being lost in the noise. I'll move it over with a new title, or you can copy paste if you prefer. Thanks!
     
  13. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,179
    That's fine! -- I really don't mind as long as it actually gets seen and discussed!

    Hopefully this didn't come across in a negative way.

    I love Unity and very much appreciate the effort that goes into coming up with and implementing great ideas like SceneVis to handle common issues with Unity. I simply wanted to point out some holes I'm seeing in the thinking behind things like this and offer ideas for ways of thinking about potential solutions. I know I tend to think about things a lot differently than most, but sometimes my insights can be valuable to the right listener. Hopefully that is the case here.
     
    gabrielw_unity likes this.
  14. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    727
    No worries - and done! :)
     
  15. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    100
    Hi guys,
    I am having some issues with the picking and visibility flags: they don't work for GameObjects with editor flags HideFlags.DontSave.
    I tried using both the hierarchy windows and the scripting API.
    Why is that, and is there any workaround?
    Thanks
     
  16. neil_devine

    neil_devine

    Unity Technologies

    Joined:
    Apr 8, 2018
    Posts:
    17
    Hi !
    The persistent part of the system requires the objects to be saved and therefore induces this limitation. There is no workaround that I know of unfortunately.
     
  17. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,179
    My major question is -- are we supposed to be deprecating the HideFlags from our workflows?
    What are we working toward to use to replace their use in our projects?
     
    Last edited: Jan 24, 2020
  18. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    100
    Thank you for the information.
    It's quite a shame :(
    I hope it would be possible to control these flags on DontSave objects (very useful for procedurally generated objects) someday, without the persistent part of the feature.
    Thanks
     
  19. neil_devine

    neil_devine

    Unity Technologies

    Joined:
    Apr 8, 2018
    Posts:
    17
    We will investigate the feasibility and how much users value the persistence
     
  20. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    100
    Thanks for your understanding.
    In my usecase, I don't care about persistency for DontSave objects, since the DontSave objects are all children of a persistent one. So basically I would like to be able to control the visibility/picking flags of the DontSave sub-objects from my root persistent object using the visibility and picking events from the API.
     
    awesomedata likes this.
  21. neil_devine

    neil_devine

    Unity Technologies

    Joined:
    Apr 8, 2018
    Posts:
    17
    Did a preliminary investigation, looks like it could be possible to remove this limitation in its current form. Please enter a bug if you don't mind, it will help us both track the progress.
     
  22. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    100
    Thanks
    Bug has been reported with ticket ID 1217361.
    Cheers
     
  23. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    434
    @gabrielw_unity @neil_devine We're testing updating from 2019.2 to 2019.3 and hit the scene picker not working in the DontDestroyOnLoad scene - the setting is ignored and things are pickable all the time.

    The picking in DontDestroyOnLoad problem was mentioned in a previous post (#141). Did this happen to be bug reported and/or fixed? Thanks for any info.
     
  24. neil_devine

    neil_devine

    Unity Technologies

    Joined:
    Apr 8, 2018
    Posts:
    17
    Hi @greg-harding I have not seen this come through and cannot find it in the bug database, if you could go ahead and report this we will get to it as soon as possible.
     
  25. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    434
    Hi Neil @neil_devine, thanks for your quick reply. I submitted a bug a few minutes after your post. I haven't had an email/confirmation of it but ***Updated it did finally appear in fogbugz. Case #1234777
     
    Last edited: Apr 8, 2020
  26. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,441
    Hi,
    I'm trying to use SceneVisibiltyManager on a number of objects to disable picking in the editor but I'm getting a few errors on the way.
    I have this on each script -
    Code (CSharp):
    1. if (sv == null)
    2. {
    3.     sv = ScriptableObject.CreateInstance<SceneVisibilityManager>();
    4. }
    But I'm getting an error ScriptableSingleton already exists. Did you query the singleton in a constructor?
    Am I approaching that wrong? It works okay as is but the errors are slightly disconcerting.

    Thanks,
    Pete
     
  27. neil_devine

    neil_devine

    Unity Technologies

    Joined:
    Apr 8, 2018
    Posts:
    17
    Hi @petey the reason you are getting this error is because the singleton for the manager is created and managed by the editor, there can only be one. You should be using that singleton to do your operations. You can get access to the singleton through its instance:

    SceneVisibilityManager.instance


    You will then have access to all the methods you need like

    SceneVisibilityManager.instance.Hide(...)

    SceneVisibilityManager.instance.Show(...)


    or if you want to disable just picking and still see your object

    SceneVisibilityManager.instance.DisablePicking(...)
    SceneVisibilityManager.instance.EnablePicking(...)
     
    awesomedata and petey like this.
  28. alexovi

    alexovi

    Joined:
    Dec 14, 2012
    Posts:
    1
    @neil_devine, just for curiosity. Why have you started using the singleton patterns? In past all 'singletons' were implemented just with static methods.
     
  29. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,179
    Because he is a fan of "The Highlander" and the above explains it all.
     
  30. Ludiq

    Ludiq

    Joined:
    Mar 6, 2015
    Posts:
    669
    Hi!

    I'm trying to have a custom camera cull the objects hidden via the scene visibility tools.

    (I need to do this because I'm implementing a custom camera mode for the scene view).

    I tried the following but I can't seem to get it to work:

    Code (CSharp):
    1. var camera = // my custom camera
    2. var sceneView = SceneView.lastActiveSceneView;
    3. camera.cameraType = CameraType.SceneView;
    4. camera.scene = sceneView.camera.scene;
    5. camera.overrideSceneCullingMask = sceneView.camera.overrideSceneCullingMask;
    Is there any other setting I need to set or other API I could call?

    EDIT: Strangely, this seems to work for my terrain object (the relevant line is setting the CameraType to SceneView), but not for my other renderers. What's the logic here?
     
    Last edited: Jul 14, 2020
  31. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    389
    The visibility flag is only culled in the editor camera drawing render path, so you will need to use Handles.DrawCamera to render your camera instead of the usual Camera.Render. Make sure to set DrawCameraMode to something other than DrawCameraMode.Normal, (ex, use Textured) as Normal mode is treated as a regular Camera.Render call.

    Note - I haven't tested this. There may be additional setup that is not mentioned.
     
  32. Ludiq

    Ludiq

    Joined:
    Mar 6, 2015
    Posts:
    669
    Thanks! Handles.DrawCamera did the trick. :)
    I used DrawCameraMode.UserDefined.
     
    kaarrrllll likes this.
  33. Camarent

    Camarent

    Joined:
    Feb 19, 2014
    Posts:
    87
    Hi! I met strange behaviour for scene picking tools caused by prefabs.
    In short, if I disable parent and enable children pickability I still can pick parent if it is prefab.
     

    Attached Files:

  34. Camarent

    Camarent

    Joined:
    Feb 19, 2014
    Posts:
    87
    One more variation of behaviour if nested prefabs after override used.
     

    Attached Files:

unityunity