I want to change the default skybox material so I made this lines... After that I only see blue... What's my mistake?
the material is on the Assets folder by the away
Material levelMat = Resources.Load(Application.dataPath + "/testeVR.mat", typeof(Material)) as Material;
RenderSettings.skybox = levelMat;
You can't place the material in the Asset folder if you are loading it with
Resources.Load
.The
levelMat
variable isnull
. You get blue when the material you are applying to the Skybox is null and you can prove this by addingDebug.Log(levelMat);
after it.You can't do this either. The
Application.dataPath
should not be used in the path parameter of theResources.Load
function.Few things to understand from your code:
1.
Resources.Load
requires a special folder called Resources. Create a folder called Resources in the Assets directory then place the testeVR.mat inside it.2.You do not put the file extension in the path parameter of the
Resources.Load
function. So, testeVR.mat should actually be testeVR without ".mat".Simply create a folder called Resources in the Assets Folder then place the testeVR material inside this place. It should look like this: Assets/Resources/testeVR.mat. The code below should be used to load it.
Now, lets say that you have another folder called "Mats" which is in the Resources folder. You would use something like below: