Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    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:
    4
    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:
    235
    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