Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    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:
    72
    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:
    213
    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:
    10
    Oh nooo that would be the fit for my game!
     
  6. Slyrae

    Slyrae

    Joined:
    Aug 28, 2017
    Posts:
    1
    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.
     
    newsec, april_4_short and Avalin like this.
  7. DonJorris

    DonJorris

    Joined:
    Mar 29, 2016
    Posts:
    2
    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:
    213
    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.
unityunity