Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Freeform Light2D shapePath is fixed length

Discussion in 'Graphics Experimental Previews' started by me_gone_mad1, Jun 18, 2019.

  1. me_gone_mad1

    me_gone_mad1

    Joined:
    Feb 2, 2018
    Posts:
    9
    Im looking to use Light2D to create a dynamic shaped light, this would require potentially having a different number of vertex. Currently i can change the shape as the array isn't read only:
    light2D.shapePath[0]=Vector3.up;


    but since shape path is a get only property you cant resize it using something like
    Array.Resize(ref light2D.shapePath, light2D.shapePath.Length+1);


    and as said before being a getter only you cant do
    light2D.shapePath = new []{Vector3.up, Vector3.down, Vector3.right};


    so... short of a super nasty force the array to be huge then hide unneeded vertex on top of each other, which due to the manual entry method of each point in the inspector i dont think this is realy possible yet.

    would be cool if in the next version their is a way to formals update the shape, till then anyone know any good work arrounds?
     
  2. YilianSource

    YilianSource

    Joined:
    Jan 11, 2018
    Posts:
    1
    For anyone curious, the way that Unity does it internally is via SerializedObjects, which can't be used during runtime, since it's UnityEditor only.

    Dirtiest workaround possible ... using reflection to set the value of the
    private Vector3[] m_shapePath
    .
     
  3. me_gone_mad1

    me_gone_mad1

    Joined:
    Feb 2, 2018
    Posts:
    9
    that sucks how deep in technical debt is it? is it likely to ever happen given its still so experimental?
     
  4. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    911
    More than a year later...

    tenor.gif
     
unityunity