docs.unity3d.com
Search Results for

    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
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)