I have a small question on Unity. I have 2 scenes; one is a 'menu' with a simple button, and the other one is my scene with an object that has a custom terrain shader with it. You can see the code for the custom shader here:
Unity shader error, unrecognised identifier
For some reason, I am being presented with this situation where:
If Game scene is run in editor -> the shader is loaded
If Menu scene is run in editor and then go to Game scene -> the
shader is loaded
If Game scene is run after build -> the shader is loaded
If Menu scene is run after build and then go to game scene -> the
shader is NOT loaded
Any idea what is going on here?
Related
I created a simple application which is a menu containing 4 scenes.
Scene 1 = using Vuforia, I replace marker with a 3D Object
Scene 2 = you can click on a 3D sphere
Scene 3 = you can click on a 3D cube
Scene 4 = you can click on a 3D pyramid
My main focus is the scene 1 actually.
The problem
When I was testing this scene in Unity, Vuforia would automatically use my webcam as a camera and I could look for marker as you can see on this picture :
Now I got my hands on the Hololens, using Holographic Remoting Player I keep getting this mesh on every scene I created (this picture is from Unity but I see the exact same in the Hololens) :
What I've tried
I looked for element using a Mesh Renderer but if I disable this element, then the virtual element doesn't appear anymore.
I also took a look into the MRTK Camera settings which are the following ones :
But I can't figure out how to remove this black backgrounded mesh that appears on each of my scene.
I figured it out, so for anyone having this issue the solution is to set the MRTK - Spatial Awarness display option to Occlusion
This is a screenshot of the original Game scene the cube is white :
and this screenshot is of the directional lightning in the same Game scene :
Then this is the same scene with the same cube settings and directional lightning settings after i loaded the scene from another scene by pressing a button :
and the directional lightning. to make the cube white again i need to change the directional lightning intensity value from 1 to something higher.
If every object settings are the same camera , directional light and the cube why when loading the scene from another scene the cube is not white and i need to change the intensity value ?
Maybe because in the scene i'm loading the Game scene from the main camera Clear Flags is setting to Solid Color and also the Background is not the same as in the Game scene ? but why is that will make any changes when loading the Game scene ? I'm not sure what is going on. also when i'm loading only the Game scene and running the game only with the Game scene everything is fine with the cube only when loading the scene from the other scene then this cube change happens.
When render pipeline you're using?
If it is URP, you have to set it to lit version of the shader if you want it to be lit by the light present in scene. If you decide to set it o unlit, it remain the same in all cases.
We have two scene, in one scene we create level design and mechanics for VR in runtime, and other scene we use SteamVR for VR mode. Shader show up in editor scene but doesn't work in VR scene.
Thank you for your answers,
Actually it was a save load problem. We use 3th party asset from unity asset store (Runtime Save & Load) and SceneAssetLibrary.asset that hold scene asset references was overwritten when worked on scene. So we revert that file thus it worked again.
This question already has answers here:
Objects in Scene dark after calling LoadScene/LoadLevel
(7 answers)
Closed 5 years ago.
I have a menu scene which goes to the game scene by calling SceneManager.LoadScene method.
Everything is alright when I build the game and play (or play in editor starting from the game scene).
But when I play the game in the editor (starting from the menu) the game scene is darker than usual.
That's not hurting me, but I'm curious to know the reason.
By the way, I have only the one default directional light which unity creates.
Screenshots:
Normal (Playing the game after build)
Darker (Playing the game in editor starting from the menu scene)
You have to disable the contious light baking.
In order to do so in Unity 2017.1, go to Window -> Lighting -> Settings and uncheck Auto Generate at the bottom of the window. Then, press Generate Lightning to bake the lighting once manually.
Note that if you add more lights or make some changes, you have to bake the lightmap again.
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.