- Home /
RenderSettings.skybox script edit does not work
I wrote this little script to change the skybox anytime the player interacts with a series of objects, but it does not work, usually the first time I use it works perfectly, the second time it doesn't change anything anymore. And when I export it the build does not do it. Here's the script:
using UnityEngine;
using System.Collections;
public class SkyboxBugger : MonoBehaviour {
public Material Down;
public Material Sunny;
public Material Night;
void Start () {
}
// Update is called once per frame
void Update () {
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width/2, Screen.height/2, 0));
if(Physics.Raycast(ray, out hit, 2))
{
if(hit.collider.tag == "Buya")
{
if( Input.GetButton ("Fire1") ) {
//Change skybox
RenderSettings.skybox = Down;
}
}
if(hit.collider.tag == "Computer")
{
if( Input.GetButton ("Fire1") ) {
//Change skybox
RenderSettings.skybox = Sunny;
}
}
if(hit.collider.tag == "JoyStation")
{
if( Input.GetButton ("Fire1") ) {
//Change skybox
RenderSettings.skybox = Night;
}
}
}
}
}
Answer by Saiansh2525 · Jun 19, 2020 at 03:35 AM
Check if the materials are assigned and check the console for any logs. Also, here is a documentation on RenderSettings.skybox: https://docs.unity3d.com/ScriptReference/RenderSettings-skybox.html
The way you assigned the skybox looks right so it is probably another problem.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Targeting system, can select but won't deselect... 0 Answers
C# Raycast shots not hitting targets (3D) 0 Answers
Raycast doesn't work on Android(cardboard VR), but works in editor. 4 Answers