x


Changing Skybox with toggle gui button

Hi,

How can I change the skybox material?

more ▼

asked Mar 18, 2010 at 11:55 PM

maveryck21 gravatar image

maveryck21
299 94 76 92

This is a combination of two problems: How to make a GUI Toggle, and how to change the Skybox. If you can break your questions down into the composite elements and then post those as individual questions, there's a bigger chance that other people may also find the questions and answers useful (because they're more general).

Mar 19, 2010 at 10:15 AM runevision ♦♦
(comments are locked)
10|3000 characters needed characters left

3 answers: sort oldest

The GUI.Toggle function returns the state of the toggle. true = on, false = off

toggleState = GUI.Toggle(toggleRect, toggleState, "toggle");
more ▼

answered Mar 19, 2010 at 01:13 AM

Eric5h5 gravatar image

Eric5h5
111k 55 189 675

(comments are locked)
10|3000 characters needed characters left

I've found out the solution..here is the code I'm using

    toggleDayNightNew = GUI.Toggle (Rect(25, 20, 80, 30), toggleDayNight, "Day/Night");
    if(toggleDayNightNew != toggleDayNight)
    {
        if(toggleDayNightNew == true)
        {
            GameObject.Find("CrateCamera").GetComponent("toggleSky").applyDaySky();
        }
        else
        {
            GameObject.Find("CrateCamera").GetComponent("toggleSky").applyNightSky();
        }
        toggleDayNight = toggleDayNightNew;
    }

more ▼

answered Mar 19, 2010 at 12:17 PM

maveryck21 gravatar image

maveryck21
299 94 76 92

(comments are locked)
10|3000 characters needed characters left

var dayMaterial:Material; var nightMaterial:Material; private var ButtonText:String ="day"; RenderSettings.skybox = dayMaterial;

function OnGUI () { if (GUI.Button (Rect (10,10,150,50), ButtonText)) { if (RenderSettings.skybox == dayMaterial){ ButtonText = "night"; RenderSettings.skybox= nightMaterial; }else if(RenderSettings.skybox == nightMaterial){ ButtonText = "day"; RenderSettings.skybox= dayMaterial; } } }

more ▼

answered Jul 26, 2010 at 05:17 PM

alfrido gravatar image

alfrido
36 2

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x260
x255

asked: Mar 18, 2010 at 11:55 PM

Seen: 6325 times

Last Updated: Jul 25, 2012 at 10:29 PM