Help please - How to change SkyBox with a button on Gui

Hello,

I’m making a unity game and i want to know how can i change the skybox pressing a button

I have already a script found in the older versions of unity, but in unity 5.5 it gives me error on " : " in the var sky material

Using unity.engine
Using unity.collections ... i'm on a smartphone ...

But the main script is:

var sky1 : Material;
var sky2 : Material;
var sky3 : Material;
function OnGUI () {
if(GUILayout.Button ("Sky 1"))
{
    RenderSettings.skybox = sky1;
}
if(GUILayout.Button ("Sky 2"))
{
    RenderSettings.skybox = sky2;
}
if(GUILayout.Button ("Sky 3"))
{
    RenderSettings.skybox = sky3;
}
}

How can i fix that ?

Or Does anyone knows another script that can change sky on click ?

If that really is the content of your code then you’re mixing C# and UnityScript together.

Can i only use:

var sky1 : Material;
var sky2 : Material;
var sky3 : Material;
function OnGUI () {
if(GUILayout.Button ("Sky 1"))
{
   RenderSettings.skybox = sky1;
}
if(GUILayout.Button ("Sky 2"))
{
   RenderSettings.skybox = sky2;
}
if(GUILayout.Button ("Sky 3"))
{
   RenderSettings.skybox = sky3;
}

??

Without using

Using unity.engine …