- Home /
Question by
austint30 · Jan 15, 2014 at 01:39 AM ·
ifdirectional light
How to check if a GameObject is active in an if statement
I am trying to make the skybox change when the Directional Light is on or off, but I am having trouble. I looked everywhere and can't seem to find a working answer.
Code:
#pragma strict
var light : GameObject;
var NightSky : Material;
var DaySky : Material;
function Start () {
}
function Update () {
if ( light.active(false)){
RenderSettings.skybox = NightSky;
}
if ( light.active(true)){
RenderSettings.skybox = DaySky;
}
}
Can you edit it for me so it works? Thanks a lot.
Comment
Best Answer
Answer by Owen Burk · Jan 15, 2014 at 02:53 AM
Try this
if (GameObject.activeInHierarchy === true)
{
//blah blah blah blah
}
This is a link --> http://docs.unity3d.com/Documentation/ScriptReference/GameObject-activeInHierarchy.html
C#
if (GameObject.activeInHierarchy == true)
{
//blah blah blah blah
}
Your answer
Follow this Question
Related Questions
How are the if's in a GUI.Toolbar handled? 1 Answer
C Sharp int equal 1 or <4 && >15 1 Answer
If statement is not working properly 1 Answer
Problem with IF with 2 outputs. 1 Answer
GUI box open on MouseButtonDown 1 Answer