docs.unity.cn
    Show / Hide Table of Contents

    Unmanaged components

    Unmanaged components store the most common data types which means they're useful in the majority of use-cases.

    Unmanaged components can store fields of the following types:

    • Blittable types
    • bool
    • char
    • BlobAssetReference<T> (a reference to a Blob data structure)
    • Collections.FixedString (a fixed-sized character buffer)
    • Collections.FixedList
    • Fixed array (only allowed in an unsafe context)
    • Other structs that conform to these same restrictions

    Create an unmanaged component

    To create an unmanaged component, create a struct that inherits from IComponentData.

    The following code sample shows an unmanaged component:

    public struct ExampleUnmanagedComponent : IComponentData
    {
        public int Value;
    }
    

    Add properties that use compatible types to the struct to define data for the component. If you don't add any properties to the component, it acts as a tag component.

    Additional resources

    • Tag components
    • Managed components
    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Wednesday, June 21, 2023