Search Unity

Is it possible to change falloffIntensity from script?

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

  1. Avalin


    Oct 12, 2018
    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


    Unity Technologies

    Apr 19, 2018
    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.