docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Transform usage flags

    Transform usage flags control how Unity converts Transform MonoBehaviour components to entity data. You can use the values in TransformUsageFlags to define what transform components are added to the entities during the baking process.

    The flags help reduce the number of unnecessary transform components in baked entities. The following flags are available:

    • None: Indicates that there are no specific transform component requirements. However, other bakers can add TransformUsageFlags values to the entity.
    • Renderable: Indicates that an entity requires the necessary transform components to be rendered, but it doesn't require the transform components to move the entity at runtime.
    • Dynamic: Indicates that an entity requires transform components to move at runtime.
    • WorldSpace: Indicates that an entity must be in world space, even if it has a dynamic entity as a parent.
    • NonUniformScale: Indicates that an entity requires transform components that represent non uniform scale.
    • ManualOverride: Ignore all TransformUsageFlags values from other bakers on the same GameObject. No transform components are added to the entity.

    Unity requires these flags whenever an entity is accessed in a baker. Also, the bakers for default GameObject components automatically add the appropriate transform usage flags to the baked entities. For example, the baker for MeshRenderer adds Renderable as a transform usage flag.

    Use transform usage flags

    You can use more than one flag on an entity and Unity combines the flags before adding the transform components to the entity. For example, if the Dynamic and WorldSpace flags are on an entity, Unity considers the entity dynamic and in world space at runtime.

    Transform usage flags are helpful if you want to reduce the number of unnecessary transform components in baked entities. For example, if you have a GameObject that represents a building, and the building has a child GameObject that represents a window, because these GameObjects won't move at runtime, both of these GameObjects have the Renderable flag. When the baking process runs, both of the entities for the these GameObjects don't need to be in a hierarchy, and their transform information can be combined in a LocalToWorld component in world space. Unity then doesn't generate a LocalTransform or a Parent for these components, saving on unnecessary data.

    Similarly, if the window GameObject is on a GameObject that represents a ship, you can mark the ship as Dynamic and keep the window as Renderable. At runtime, Unity gives the window the correct transform components (LocalToWorld, LocalTransform, and Parent) to make sure that it follows the ship around:

    public struct Ship : IComponentData
    {
        public float speed;
        // Other data
    }
    
    public class ShipAuthoring : MonoBehaviour
    {
        public float speed;
        // Other authoring data
    
        public class Baker : Baker<ShipAuthoring>
        {
            public override void Bake(ShipAuthoring authoring)
            {
                // Set the transform usage flag to Dynamic
                var entity = GetEntity(TransformUsageFlags.Dynamic);
                AddComponent(entity, new Ship
                {
                    speed = authoring.speed
                    // Assign other data
                });
            }
        }
    }
    
    Important

    Entity prefabs are automatically marked as Dynamic so the instances can be placed in the world.

    Additional resources

    • TransformUsageFlags API documentation
    • Baker overview

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Use transform usage flags
    • Additional resources
    Back to top
    Copyright © 2025 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)