docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct WeakObjectReference<TObject>

    Weak reference to an object. This allows control over when an object is loaded and unloaded.

    Namespace: Unity.Entities.Content
    Assembly: solution.dll
    Syntax
    [Serializable]
    public struct WeakObjectReference<TObject> where TObject : Object
    Type Parameters
    Name Description
    TObject

    The type of UnityEngine.Object this reference points to.

    Constructors

    Name Description
    WeakObjectReference(UntypedWeakReferenceId)

    Construct a WeakObjectReference with an existing WeakObjectReference id id.

    WeakObjectReference(TObject)

    Properties

    Name Description
    IsReferenceValid

    Returns true if the reference has a valid id. In the editor, additional checks for the correct GenerationType and the existence of the referenced asset are performed.

    LoadingStatus

    Get the loading status of the referenced object.

    Result

    The value of the referenced object. This returns a valid object if IsLoaded is true.

    Methods

    Name Description
    Equals(WeakObjectReference<TObject>)

    Indicates whether the current object is equal to another object of the same type.

    GetHashCode()

    Gets the hash code of this reference.

    LoadAsync()

    Directs the object to begin loading. This will increase the reference count for each call to the same id. Release must be called for each Load call to properly release resources.

    Release()

    Releases the object. This will decrement the reference count of this object. When an objects reference count reaches 0, the archive file is released. The archive file is only unloaded when its reference count reaches zero, which will then release the archive it was loaded from. Archives will be unmounted when their reference count reaches 0.

    ToString()

    String conversion override.

    WaitForCompletion(int)

    Wait for object load in main thread. This will force synchronous loading and may cause performance issues.

    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)