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.
Related
I don't know if this is some sort of bug or (which is likely) I'm doing something wrong, but I have two scenes.
menuScene is a starting point and it suppose to have nothing but canvas with some input fields, sliders, labels and a button.
Clicking the button moves to gameScene, which (by default) contains some objects.
This is what I see when I run the project:
What do I need to do to make only menuScene visible on launch?
In general: Unity 2020.1.0b12 is a BETA version and not unlikely to have a lot of bugs. If you are not investigating the most newest features but rather want to implement a serious project you should stick to the latest stable Unity Version (currently 2019.4 LTS).
You have opened both your Scenes in the Editor! In your Hierarchy I can see both scenes menuScene and gameScene.
In this case SceneManager.Load loads your already existing but currently unloaded (disabled) scene (basically only enables it) but keeps the other scene(s) in place.
Note that within the Editor Multi Scene Editing is possible and even if you then start the PlayMode both scenes are still there.
However, in a build later only the top-most scene of the list in the Build Settings is loaded in single mode!
The follow up error you got is due to your scenes not added to the Build Settings. Simply drag & drop your two scenes into the list in the Build Settings.
Then open only the first scene in the Editor (click Remove on the other ones) and then enter PlayMode again. Now it should load your scenes in single mode
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.
I want to show TWO Scene simultaneously in my application.
EDITOR has not any problem. working good. but if I build for window
application show just one scene, how to fix it?
When you build the project, by default, only the first scene on your build order will be loaded as the first displayed scene. If you want to load multiple scene simultaneously, you should load the extra scenes additively on a script, for example in C#:
SceneManager.LoadScene("OtherSceneName", LoadSceneMode.Additive);
However in the editor, as you noticed, you could add two scenes and both loaded and runs normally when you hit "Play". This is just one of the editor's helpful functionality for editing multiple scene. Notice that on project hierarchy, only a single scene is recognized as the "Active scene". The editor behaves as if you loaded the active scene in "Single" mode first, then loaded the others in "Additive" mode.
Ref: https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html
The scene content is shown in game player but not shown in windows build.
Could anyone suggest what can cause to this kind of problem, Or suggest ways to troubleshoot it?
Please note that :
The scene is properly defined in the build settings
I am using windows 10
I am building for windows
The scene contains some sprites with physics , an imported character with animations (I imported it from the asset store) , a UI canvas with a button, and some scripts that attached to the objects.
The scripts do almost nothing.
The game content is properly shown inside the game player (Unity's Editor player) the problem is only with the build.
When running the build output , Unity's splash screen is shown and then the scene is loaded but its content isn't shown.
I changed the camera background color , and the color is indeed changed in the build , it's just the scene content that isn't shown.
I added a UI canvas with a button , the button is shown.
I am using Unity 5.5.1f1
it is a 2d project
Make sure you are adding the scene to Scenes in Build screen.
Go to File->Build Settings and in the dialog make sure your scene has a check mark on the left.
When running in Editor Unity runs whatever scene you are working on, but when building a player you need to include the scene in the list.
Problem solved.
I deleted the camera and created a new one. It solved the problem.
Me and some of my mates work together on a project in Unity. When I try to load the project, one of them gave to me (via Dropbox or USB-Stick, doesn't matter), I keep seeing the empty Hierarchy-window (I don't even see a main camera), although he created some objects in the scene.
The scene is definetly loaded in the editor, the name of the scene is shown at the top of the editor. I am not even able to instantiate a prefab in that scene, prefabs from the project are shown with a grey file-symbol, not with the normal blue "prefab-symbol".
By the way: We are using Unity 5.0.x
I hope you have a solution for my problem :)
The problem was a wrong setting of the meta-files and a version-conflict of Unity. The project was created with Unity 5.0.0, opening it with Unity 5.0.1 did not work.