Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Is it possible to change falloffIntensity from script?

Discussion in '2D Experimental Preview' started by Avalin, Aug 17, 2019.

  1. Avalin

    Avalin

    Joined:
    Oct 12, 2018
    Posts:
    98
    When I try to access it, it says it is read only. I want to lerp it in a coroutine like this:


    Code (CSharp):
    1.     public IEnumerator FadeLightFalloff(Light2D lightToBeLerped, float startIntensityVal, float endIntensityVal, float amountOfSeconds)
    2.     {
    3.         float ElapsedTime = 0.0f;
    4.         float TotalTime = amountOfSeconds;
    5.         while (ElapsedTime < TotalTime)
    6.         {
    7.             ElapsedTime += Time.deltaTime;
    8.             lightToBeLerped.falloffIntensity = Mathf.Lerp(startIntensityVal, endIntensityVal, (ElapsedTime / TotalTime));
    9.             yield return null;
    10.         }
    11.     }
    but the falloffIntensity variable is read only. I can change it through the slider, however, but I want to access it from my script if possible?
     
  2. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    You can't right now. I'm going to make a pass through the API calls probably early next week. There are a few properties that we might not want to expose just yet, but that one should be one of the okay ones.
     
    Last edited: Aug 23, 2019
    Avalin likes this.
  3. alleballe90

    alleballe90

    Joined:
    Jan 9, 2017
    Posts:
    7
    did this ever happen?
     
  4. redskies88

    redskies88

    Joined:
    Jan 7, 2021
    Posts:
    1
    Doesn't seem like it has been.
     
  5. Durium

    Durium

    Joined:
    Feb 1, 2020
    Posts:
    37
    Oh nooo that would be the fit for my game!
     
  6. Slyrae

    Slyrae

    Joined:
    Aug 28, 2017
    Posts:
    4
    Why didn't this happen... Doesn't it seem like a pretty important freedom to give us? Changing intensity does not yield the same results as changing falloff would. Pretty disappointed this hasn't been addressed after 2+ years.
     
    NanoSwing, april_4_short and Avalin like this.
  7. DonJorris

    DonJorris

    Joined:
    Mar 29, 2016
    Posts:
    8
    I also need this, is there something major blocking it or was this forgotten?
     
    MousePods, Avalin and april_4_short like this.
  8. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    I'll check on this. One of the engineers on our team was assigned to work on this a while back. If it not available in the latest version of URP, I'll see if I'm still allowed to fix this.
     
    DonJorris and Avalin like this.
  9. youwho42

    youwho42

    Joined:
    Jun 18, 2016
    Posts:
    4
    Please do, this would really be ideal. Is there a work-around otherwise?
     
    AllanHouse, rrtc26 and raimis001 like this.
  10. zaidabuzahra2

    zaidabuzahra2

    Joined:
    Mar 25, 2022
    Posts:
    1
    Any updates?
     
  11. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    I know its definitely fixed the latest code (which is unreleased). I'm not sure if this fix was backported. I'll have to investigate when I get some time and figure out which versions have this change.