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

How to bind an element in a List/Array as PropertyStreamHandle?

Discussion in 'Animation Previews' started by EthanCS1993, Jul 14, 2020.

  1. EthanCS1993

    EthanCS1993

    Joined:
    Apr 6, 2018
    Posts:
    2
    For example i have this class, and i want to bind element in this data array.
    Code (CSharp):
    1. public class JobDataZone : MonoBehaviour
    2. {
    3.   public float[] data = new float[100];
    4. }
    And this code will throw an error
    Code (CSharp):
    1. animator.BindStreamProperty(animator.transform, typeof(JobDataZone), "data[0]");
     
  2. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    158
    Hi,
    The error is thrown because you cannot animate an array, or an element in an array in the animation system. Unfortunately, you'll have to limit the number of elements you want to animate your component.

    You can have a look at the `WeightedTransformArray` struct in the Animation Rigging package to look at ways we got around the issue:
    https://docs.unity3d.com/Packages/c...nimations.Rigging.WeightedTransformArray.html
     
unityunity