- Home /
Change Lighting Skybox material unity5
Hi,
I want to change the Lighting Skybox with created materials in Assets/Materials folder via C# code at the beginning of loading. Here is the code that I'm using:
void Start () {
Material skybox = RenderSettings.skybox;
Material newMat = Resources.Load("matMed", typeof(Material)) as Material;
RenderSettings.skybox = newMat;
}
But it shows only blue screen. If I assign the material to the lighting Skybox manually (by drag and drop) there is no problem. Any help is appreciated Thanks
Answer by majidnasiri · Aug 18, 2016 at 11:06 PM
I found the solution.
I created a new material before start function and assigned the Material from folder via Inspector to the material name and just called RenderSettings in the code. the final code is:
public Material newMat;
void Start () {
RenderSettings.skybox = newMat;
}
In my application, the code was attached to the main camera. When I created a new material, and save it, it doesn;t show immidiately when backed to the Unity. I switched from Camera to another GameObject and again clicked back to the camera to see the created material. Then dragged the material from folder and dropped on the newMat in the Inspector.
Your answer
Follow this Question
Related Questions
How to change the reflection according to skybox-material? 2 Answers
Multiple Cars not working 1 Answer
Change Transparency 1 Answer
Distribute terrain in zones 3 Answers
Skybox material not working 1 Answer