Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Hoping to better understand UnsafePtrList

Discussion in 'Entity Component System' started by PublicEnumE, May 9, 2021.

  1. PublicEnumE

    PublicEnumE

    Joined:
    Feb 3, 2019
    Posts:
    729
    Unity has a public unsafe collection that doesn't get a lot of attention here: Collection.LowLevel. Unsafe.UnsafePtrList

    The main meat of this structure is a
    public readonly void** Ptr;


    Is it correct that this container can be thought of as a "buffer of buffers"?

    If so, that might be really useful for one case in my code. Thanks for any help, and please advise.
     
  2. PublicEnumE

    PublicEnumE

    Joined:
    Feb 3, 2019
    Posts:
    729
    Nevermind, it looks like UnsafePtrList may be a structure designed mostly for internal use by Unity. It has some features which make it seem less useful for other users. For example, it's Length and Capacity are both readonly, and are always set to 0. And it's read-only Ptr field is set to null if you call the normal constructor.
     
    apkdev likes this.