Search Unity

Question New Game objects are not visible

Discussion in 'Editor & General Support' started by saturnuns-ringar, Mar 27, 2023.

  1. saturnuns-ringar

    saturnuns-ringar

    Joined:
    Apr 26, 2022
    Posts:
    12
    I have a project that I haven't touched in about a year so my memories of this are a bit vague. Nevertheless, I'm trying to add new Game objects to the scene but they are not visible when I run the game. Nor when I run the scene using the Play button. What I've tried so far:
    New UI-elements, such as text, are visible. And if I create a completely new project the objects are visible. So, I'm a bit stuck here. Do you have any ideas on how to fix this issue?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    The overwhelmingly likely situation is that, like in the video you shared, your objects are simply not within the camera's view frustum. Without you sharing any further details about your scene, it's hard to say any more than that.
     
  3. saturnuns-ringar

    saturnuns-ringar

    Joined:
    Apr 26, 2022
    Posts:
    12
    Thanks for the reply! And...

    I tried some different camera settings but couldn't get the objects to show. :| Also, if I create a completely new scene and just add a cube the cube isn't visible. It works just fine if I start a new project and add an object, cube or whatever the same way.

    What kind of details would be good to share? I'm a complete Unity (and 3D)- rookie and really don't know. However, here's a screenshot of the scene:
    https://i.imgur.com/6zXPyiU.png

    I tried getting that yellow sphere to show, but it's just not gonna happen as of now. :/
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    Steps to success:

    - fast-remake one of your prefabs (doesn't matter which one)

    - look at it and understand all the parts in the inspector: renderer, source image or mesh, texture, material, whatever

    - now pull up one that is invisible.

    - figure out how they're different (eg, missing texture, missing sprite, missing mesh, missing a component, etc)

    - fix the discrepancy(s)

    Remember this also:

    SCRIPTS OR ASSETS ARE MISSING OR BLANK

    Some info about Missing script warnings, broken prefabs, GUIDs, renaming GUIDs, etc:

    https://forum.unity.com/threads/problem-with-git-and-missing-scripts.1090876/#post-7024801
    https://forum.unity.com/threads/scr...ead-after-loading-editor.998413/#post-6487297
    https://forum.unity.com/threads/scr...ead-after-loading-editor.998413/#post-6488230

    EVERYTHING in Unity is connected to the above GUID, which is stored ONLY in the metafile, and hence why the metafiles ALWAYS MUST be source-controlled.

    When Renaming: It is super-easy to inadvertently change the GUID by renaming outside of Unity. Don't do that. Instead:

    - close Visual Studio (important!)
    - rename the file(s) in Unity
    - in Unity do Assets -> Open C# Project to reopen Visual Studio
    - now rename the actual classes, and MAKE SURE THE FILE NAMES DO NOT CHANGE!

    If you are NOT using source control while you do this, renaming files is an EXTREMELY dangerous process. Use source control at all times so that you can trivially revert if you miss a critical step and damage your project.

    PROPERLY CONFIGURING AND USING ENTERPRISE SOURCE CONTROL

    I'm sorry you've had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.

    Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

    You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.

    As far as configuring Unity to play nice with git, keep this in mind:

    https://forum.unity.com/threads/prefab-links-keep-getting-dumped-on-git-pull.646600/#post-7142306

    I usually make a separate repository for each game, but I have some repositories with a bunch of smaller test games.

    Here is how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up an appropriate .gitignore file for Unity3D:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    Generally setting Unity up (includes above .gitignore concepts):

    https://thoughtbot.com/blog/how-to-git-with-unity

    It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It's simply ridiculous not to back up.

    If you plan on joining the software industry, you will be required and expected to know how to use source control.

    "Use source control or you will be really sad sooner or later." - StarManta on the Unity3D forum boards
     
  5. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    Very unclear screenshot but it just looks like your camera is looking down and away from all of the objects in the scene.
     
  6. saturnuns-ringar

    saturnuns-ringar

    Joined:
    Apr 26, 2022
    Posts:
    12
    I haven't used any prefabs (it's a very simple game). However, I duplicate a game object in the scripts.

    This seems like a bit of a rabbit hole. I have renamed files outside of Unity.

    I use git and the GitHub desktop client for Linux. I didn't really liked using git in the Unity IDE. Probably I never ever even got it to function with github. :/
     
  7. saturnuns-ringar

    saturnuns-ringar

    Joined:
    Apr 26, 2022
    Posts:
    12
    The objects are all scattered outside the view. I move them in place with scripting. I'll try to move the camera around when the game is running and see if I can find the non-visible objects. However, I find it strange that my objects in a completely new, default, scene aren't visible?!
     
  8. saturnuns-ringar

    saturnuns-ringar

    Joined:
    Apr 26, 2022
    Posts:
    12
    I figured this out. My camera and the position of the objects were a bit strange, I believe. I'm not sure why the objects and the camera has been positioned like this, but I guess it made sense back when I created them (about a year ago). What really confused me was the the new objects weren't visible in my new scenes. I haven't looked into that problem, but I guess it will be a similar problem. Thanks for the replies, folks!