Unity: suddenly some gameobjects stopped beeing shown - unity3d

I'm a Computer Science
Engineering student. I'm currently working on a Uni project using Unity to build a 2D game. Until this morning everything was fine, but suddenly after some work on a UI Manager Script in my menu scene (Scene 0) when I tried to play the game some gameobjects (apparently random) stopped to be visualized on Scene View and on Game View in the Level scene (Scene 1).
I can see all gameobjects fine on camera preview and they all are active in the hierarchy, even all colliders are working.
I tried to look on the web, but I can't find any solution or any similar case...
I don't really have any ideas, I'll be really glad if someone can help me. Thanks.

Check the Material variable on the Sprite Renderer component and make sure it's set to "Sprites-Default". In my case, the material for the hidden objects had somehow changed to "None" while I was working on a little postprocessing effect.
Edit: Here's how the material changed. Adding a SpriteGlow script from a package which works with postprocessing had first turned the objects' SpriteRenderer material from the original "Sprites-Default" to "Sprite/Outline". Upon removing the SpriteGlow script component from the object, the material became "None" rather than defaulting back to "Sprites-Default" and that was when I stopped seeing the objects even though they were present in the scene. This is most likely your problem too since you said every other thing like collision works and the objects are definitely present in the scene.

Related

Floppy Disk icon Middle of my screen when game is running

I'm a beginner in unity and programming, I was following a video for making a Flappy Bird game. Everything works perfectly but when I run the game, I get a floppy disk icon middle of the screen and somehing called DontDestroyOnLoad starts working out of nowhere. I couldn't find or understand anything on google when I search for it. I'm posting the screenshots in case anybody wanna see it.
This icon and dontdestroyonload thing only appears when game is being run:
There's a little button in the type right of your scene and game view called "Gizmos", un-toggle that button, should fix your issue.
Also don't worry, Gizmos can only be seen in the Unity Editor for level editing and debugging purposes --> if you were to build the game, for instance on IOS, they would disappear.
(if this doesn't fix your issue, then I would just create a new scene and copy your gameobjects over one-by-one)
I see someone responded about the main part of a problem, but I'll clarify about dontdestroyonload
Don't destroy on load is collection of objects that won't be destroyed when new scene will be loaded, usually objects there come from running them through DontDestroyOnLoad method somewhere in a script, however I noticed that some time ago Unity creators started to put there some stuff related to built-in tools (like debug)

URP Shader Graph shaders time node doesn't work in certain situations

I have several shaders that use the Time node to animate certain UI elements for my mobile game.
In certain cases (which I am unable to reproduce), the shaders will be stuck on a specific time and not animate.
For example, a shine shader might be stuck mid-shine.
Some important things to note:
Time.timeScale is 1 - all my tweens using scaled delta time are working correctly
When this happens all shaders using the time node in the active scene will "freeze in time"
This only reproduces on actual Android devices (iOS untested)
All parameters affecting time in said shaders are positive, valid numbers
There are no errors or warnings
When I transition from my main menu scene to the game scene, time based shaders will work correctly - when I come back to the main scene, it will reproduce again (obviously it's something specifically there)
Running on Unity 2019.4.11f1 with URP & Shader Graph 7.5.1, but it did reproduce in older versions of Unity/URP as well
Sample shader - The preview actually looks exactly like the issue as it will appear in game when frozen:
For any lost souls who stumble upon this issue (although I doubt it's by design as it seems like a bug).
The problem is that time isn't updated in shaders in scenes without a camera.
The camera doesn't have to render anything; it just needs to exist.
My main menu is pure UI elements and had no camera; adding a camera to the scene fixed the issue.
It is important to note that this behavior only happens once you build to an Android device; not sure if it reproduces on other platforms.

Dynamically instantiated prefabs are invisible

Now I know that this is a common problem and there are so many mistakes that would lead to it, but I have searched and seen all the results and answers in unity forums and other websites, and I'm sure that I don't have any beginner-mistake that would lead to it.
My problem is -Like the title states- that I have a "platform" prefab and I have a script, attached to some game object in the scene, that instantiates a new platform every x seconds. Now, the scripts works and everything is fine, the platforms are instantiated and they are moving and functioning as they should, but I can't see anything from this!
I mean that I can see them in the scene view window, where everything is fine, but in the game view window nothing appears, though I can interact with the platforms, such as landing on them and so on...
check the z depth... your probably instantiating them behind your camera. a good way to check is to start the game, go to scene, and take it out of 2d, then click one of the platforms in the explorer, and check its z value
It is highly possible that they are shown "behind" your background. I was making an android app and my buttons were displayed behind the UI panel. Try to instantiate your platforms as child objects of your panel.

NavMesh baking finished very quickly and does not include some objects

I am doing one of Unity's official tutorials: Survival Shooter.
Unity version: 5.3.4f1 Device: Macbook, OSX 10.11
http://unity3d.com/learn/tutorials/projects/survival-shooter/environment?playlist=17144
The problem: Baking process completes almost instantly and the floor is not highlighted by a blue mesh (where highlight should mean that navmesh is calculated for there).
Here is the screenshot of it:
Then, I checked the completed scene (which was already created by Unity Team), it showed the floor fully highlighted. I just hit the bake again without touching anything and the same problem happened. So, there must be something else as I tried the original scene file without changing anything.
What am I missing here? Is there a Unity editor setting or something like that which can break the baking process?
When baking a NavMesh for your game, a crucial thing to verify is that every object which should affect navigation is marked as a Static GameObject, or at least Static for Navigation. This setting may be found in a checkbox/dropdown at the top of the properties Inspector:
It sounds like the floor object in your scene hasn't been marked as Static, meaning it won't factor into the NavMesh baking.

Add scene when build Unity project

When I build Unity project I saw that if I add current scene Unity or not the game still run fine.
So what is the purpose of add scene ?
If you have not added any scenes then unity will build with your current opened scene by default. The purpose of adding scene is to handle among multiple scenes like Main Menu, Store, Gameplay, Gameover etc. To get more than one scene, you have to add all the relevant scenes, otherwise unity will not recognise the scene when you want to switch to another scene.
As long as #Hamza Hasan answer is correct, I think that question author means something diffrent.
He asks why he should add scene if it works fine in Editor without this action.
So the answer is, if this scene is not first default one (and it is your case), you wont be able to load it programaticaly, as it wasnt included into build even if it works in Editor. It works in Editor couse it was loaded into memory opening the scene.