using UnityEngine;
public class AddCubemap : MonoBehaviour
{
public Cubemap cubemap;
void Start()
{
if (cubemap != null)
{
Renderer rend = GetComponent<Renderer>();
if (rend != null)
{
Material mat = rend.material;
if (mat != null)
{
mat.SetTexture("_Cube", cubemap);
mat.shader = Shader.Find("Skybox/Cubemap"); // Set the shader to use cubemap
}
else
{
Debug.LogWarning("Material not found on this GameObject.");
}
}
else
{
Debug.LogWarning("Renderer component not found on this GameObject.");
}
}
else
{
Debug.LogWarning("Cubemap not assigned to the script.");
}
}
}
using UnityEngine;
public class AddCubemap : MonoBehaviour
{
public Cubemap cubemap;
void Start()
{
if (cubemap != null)
{
Renderer rend = GetComponent<Renderer>();
if (rend != null)
{
Material mat = rend.material;
if (mat != null)
{
mat.SetTexture("_Cube", cubemap);
mat.shader = Shader.Find("Skybox/Cubemap"); // Set the shader to use cubemap
}
else
{
Debug.LogWarning("Material not found on this GameObject.");
}
}
else
{
Debug.LogWarning("Renderer component not found on this GameObject.");
}
}
else
{
Debug.LogWarning("Cubemap not assigned to the script.");
}
}
}