Search Unity

Changing Sunshaft intensity with another script

Discussion in 'Scripting' started by JasonH_1981, Feb 6, 2012.

  1. JasonH_1981

    JasonH_1981

    Joined:
    Dec 20, 2011
    Posts:
    10
    Hello Unity Forum, got one that has me stumped (though that seems to happen quite a bit and for very simple reasons).

    I'm trying to change the values of my Unity Pro standard SunShafts using a javascript. I've been able to turn the entire component on and off using a "GetComponent" line, but that more fine-tuning level steps seem to not listen to whatever terminology I'm using. Right now i've got:
    //---------------------------
    var SunShafts : SunShafts;
    SunShafts = GetComponent("SunShafts");

    function Update ()
    {
    SunShafts.enabled = true;

    }
    //---------------------

    this...makes the SunShafts true. Was hoping to increase/decrease their intensity with the intensity of the directional light playing the part of my sun. Found it quite out of place to have long white SunShafts during a night mission setup. For now, I can simply turn them off entirely once a certain time limit is reached, but am hoping to make it a bit more gradual of a change. Thanks in advance for any assistance given!
     
  2. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    OK, well this post is over two years old, but in case you still need to do this, or in case anyone else searching around needs to do this, you can use the following...

    Code (CSharp):
    1. SunShafts.sunShaftIntensity = 1.0;
    the component variable names don't always match what's written in the inspector. To reference the actual variable names that you can access and change, simply open up the "SunShafts.js" script file.