39 lines
654 B
C#
39 lines
654 B
C#
using UnityEngine;
|
|
|
|
public class SkyboxReplacer : MonoBehaviour
|
|
{
|
|
public Cubemap skyCube;
|
|
|
|
private Material _skyboxMaterial;
|
|
|
|
private Material skyboxMaterial
|
|
{
|
|
get
|
|
{
|
|
if (_skyboxMaterial == null)
|
|
{
|
|
Shader shader = Shader.Find("Skybox/Cubemap");
|
|
if ((bool)shader)
|
|
{
|
|
_skyboxMaterial = new Material(shader);
|
|
_skyboxMaterial.name = "Skybox";
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("Couldn't find " + shader.name + " shader");
|
|
}
|
|
}
|
|
return _skyboxMaterial;
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
if ((bool)skyCube)
|
|
{
|
|
skyboxMaterial.SetTexture("_Tex", skyCube);
|
|
RenderSettings.skybox = skyboxMaterial;
|
|
}
|
|
}
|
|
}
|