Search Unity

DynamicBuffer.CopyFrom(T[])

Discussion in 'Entity Component System' started by digitaliliad, May 20, 2019.

  1. digitaliliad

    digitaliliad

    Joined:
    Jul 1, 2018
    Posts:
    64
    I want to store Input.touches in a DynamicBuffer, but when I call DynamicBuffer.CopyFrom(T[]) with the parameter being Input.touches, I get an error that I cannot convert from 'UnityEngine.Touch[]' to 'Unity.Collections.NativeArray<MyBufferElement>'. MyBufferElement just has a public Touch field. What am I missing?
     
  2. Singtaa

    Singtaa

    Joined:
    Dec 14, 2010
    Posts:
    492
    You need to do
    buffer.Reinterpret<Touch>().CopyFrom(touches);
     
    florianhanke and digitaliliad like this.