docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Property ValueRW

    ValueRW

    Returns a writable reference to the component value itself.

    Declaration
    public ref T ValueRW { get; }
    Property Value
    Type Description
    T
    Remarks

    This value is a reference to the actual component data. It is safe to use this field directly, e.g. "Data.ValueRW.SomeField = 123". It is also safe to make a copy of this value, e.g. "var myComponent = Data.ValueRW". Keeping a ref ("ref var myref = Data.ValueRW" is inherently unsafe as any structural change may invalidate this reference, and there is no way to detect this. It is safe to use this reference locally if you can guarantee that no structural changes will occur in between acquiring it and using it. Do not hold on to such a reference for any extended amount of time.

    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)