Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Question Win64 build no contents/scene empty when game runs

Discussion in 'Editor & General Support' started by aquamaniac, Mar 30, 2023.

  1. aquamaniac

    aquamaniac

    Joined:
    Nov 28, 2016
    Posts:
    5
    Hey everyone,

    I somehow broke my scene or my build, dunno. I started a new project yesterday (3d core) and installed the URP package. Then I imported a FBX, set up a material and post-processing and went on fiddling with lighting. All of a sudden there's no content rendered when I build and run the project on Windows 10. I changed the skybox to a solid color to check if the correct scene is loaded which is the case. It's just that nothing else is rendered, no FBX model, no base plane, not a single cube that I added testwise.

    I also made sure that the scene is listed in the build settings, it's the only scene in there and it's also checked.

    Want has possibly gone wrong? Did I mess up a setting by accident? Is there any way to get some console or debug info during runtime, e.g. entity count, vertex count etc.?

    Any help is much appreciated.
    Thanks in advance.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    33,681
    There is... that's probably the best place to start... google up "view console in built unity game" or somesuch.

    If you don't see anything horrible like a crash in the console, then time to start adding your own spew to the console and seeing if it comes out, find out if any of the code is even running.

    You must find a way to get the information you need in order to reason about what the problem is.

    Once you understand what the problem is, you may begin to reason about a solution to the problem.

    What is often happening in these cases is one of the following:

    - the code you think is executing is not actually executing at all
    - the code is executing far EARLIER or LATER than you think
    - the code is executing far LESS OFTEN than you think
    - the code is executing far MORE OFTEN than you think
    - the code is executing on another GameObject than you think it is
    - you're getting an error or warning and you haven't noticed it in the console window

    To help gain more insight into your problem, I recommend liberally sprinkling
    Debug.Log()
    statements through your code to display information in realtime.

    Doing this should help you answer these types of questions:

    - is this code even running? which parts are running? how often does it run? what order does it run in?
    - what are the names of the GameObjects or Components involved?
    - what are the values of the variables involved? Are they initialized? Are the values reasonable?
    - are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)

    Knowing this information will help you reason about the behavior you are seeing.

    You can also supply a second argument to Debug.Log() and when you click the message, it will highlight the object in scene, such as
    Debug.Log("Problem!",this);


    If your problem would benefit from in-scene or in-game visualization, Debug.DrawRay() or Debug.DrawLine() can help you visualize things like rays (used in raycasting) or distances.

    You can also call Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene manually, looking for all the parts, where they are, what scripts are on them, etc.

    You can also call GameObject.CreatePrimitive() to emplace debug-marker-ish objects in the scene at runtime.

    You could also just display various important quantities in UI Text elements to watch them change as you play the game.

    If you are running a mobile device you can also view the console output. Google for how on your particular mobile target, such as this answer or iOS: https://forum.unity.com/threads/how-to-capturing-device-logs-on-ios.529920/ or this answer for Android: https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/

    If you are working in VR, it might be useful to make your on onscreen log output, or integrate one from the asset store, so you can see what is happening as you operate your software.

    Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.

    Here's an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:

    https://forum.unity.com/threads/coroutine-missing-hint-and-error.1103197/#post-7100494

    When in doubt, print it out!(tm)

    Note: the
    print()
    function is an alias for Debug.Log() provided by the MonoBehaviour class.
     
  3. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,313
    If you make a development build you should be able to connect the debugger and get console logs. You can also connect the frame analysis tool to step through the render frame and ensure that everything is getting rendered.

    Also ensure your camera is actually pointing at the objects you're trying to view in your build.
     
  4. aquamaniac

    aquamaniac

    Joined:
    Nov 28, 2016
    Posts:
    5
    Thank you both for your immediate replies. So far I only started and hence my scene just has a tiny FBX model (or now just a cube primitive) with URP render pipeline and some bloomish material. No scripts, no code at all, just plain simple. It did run properly the first couple tries, then suddenly it stopped.

    Camera is on and pointing directly to that cube, I can see it being renderer in the Game view in the editor. The frame tool shows a bunch of stuff I clearly don't understand but there's also rendering stuff going on, some fraction of a millisecond is spent on actual rendering. Just can't say whether this is the cube or just the scene environment.

    I also did run it as a dev build and had VS attached to it. No errors, no console logs, nothing. Build succeeds after ~7 seconds and the splash screen is shown. Right after that my scene is rendered (I can tell it's the right one cuz I can clearly see the bloom from the global post-processing volume) but no geometry at all is visible. All layers are on, there's no warning, errors whatsoever.

    I guess I'll just have to start over again.
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    33,681
    That's not a useful way to proceed.

    You really should consider the debugging steps above.

    It could be something as silly as you put a Rigidbody on the cube and it falls out of sight before the first frame renders.

    Or really anything. That's why we debug.
     
  6. aquamaniac

    aquamaniac

    Joined:
    Nov 28, 2016
    Posts:
    5
    I actually did consider these steps and I tried as far as it makes sense. I don't see any benefit in spitting debug logs anywhere if zero code is involved in my scene. I have no rigid bodies, there's nothing physical going on, it is a dead simple scene with a cube (or a hex floor tile before), a directional light and the main camera. All I did was playing around with lighting and post-processing.

    I attached VS and kept observing the output for anything suspicious, there just hasn't been literally anything.

    Scene Viewport:


    In-Editor Game View:


    Build-Win64:
     
  7. aquamaniac

    aquamaniac

    Joined:
    Nov 28, 2016
    Posts:
    5
    Nevermind, it seems like I accidentally checked Accurate G-buffer normals in the Rendering Path settings of the URP renderer. I don't remember changing anything there manually but unchecking that option clearly fixes the issue.
     
    Kurt-Dekker likes this.
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    33,681
    It would prove your first scene is loading. It could have become silently corrupt in some way that the built engine is incapable of loading but the editor can load. :)

    Glad you're back in service and thanks for the reminder to take my G-buffers into the shop tomorrow for an accuracy check.
     
  9. aquamaniac

    aquamaniac

    Joined:
    Nov 28, 2016
    Posts:
    5
    Good point, I kinda did this but the other way, I added a simple rotator script to the main camera which indeed turned around it's up-axis. Also I was able to see the PP effects, so there was no doubt it's the right scene. That's why I named that thread empty scene rather than wrong scene. ;-)

    That broken G-buffer normals flag actually never came to my mind until I found a bug report regarding that very specific setting. https://issuetracker.unity3d.com/is...yer-when-accurate-g-buffer-normals-is-enabled
    It should be fixed by now in the versions listed there.
     
    Kurt-Dekker likes this.