Esempio n. 1
0
        /// <summary>
        /// Releases an internal reference to the resource held by the resources system. This allows the resource
        ///	to be unloaded when it goes out of scope, if the resource was loaded with "keepLoaded" parameter.
        ///
        /// Alternatively you can also skip manually calling <see cref="Release(ResourceRef)"/> and call <see cref="UnloadUnused"/>
        /// which will unload all resources that do not have any external references, but you lose the fine grained control
        /// of what will be unloaded.
        /// </summary>
        /// <param name="resource">Resource to release</param>
        public static void Release(ResourceRef resource)
        {
            if (resource == null)
            {
                return;
            }

            Internal_ReleaseRef(resource.GetCachedPtr());
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public override bool Equals(object other)
        {
            if (!(other is ResourceRef))
            {
                return(false);
            }

            ResourceRef otherRef = (ResourceRef)other;

            return(Internal_GetUUID(mCachedPtr).Equals(Internal_GetUUID(otherRef.mCachedPtr)));
        }
Esempio n. 3
0
        /// <inheritdoc/>
        public override bool Equals(object other)
        {
            if (!(other is ResourceRef))
            {
                return(false);
            }

            ResourceRef otherRef = (ResourceRef)other;

            UUID lhs, rhs;

            Internal_GetUUID(mCachedPtr, out lhs);
            Internal_GetUUID(otherRef.mCachedPtr, out rhs);

            return(lhs.Equals(rhs));
        }
Esempio n. 4
0
 /// <summary>
 /// Loads a resource referenced by the provided reference. If running outside of the editor you must make sure
 /// to mark that the resource gets included in the build. If running inside the editor this has similar functionality
 /// as if loading using the project library. If resource is already loaded an existing instance is returned.
 ///
 /// All resources are automatically unloaded when they go out of scope unless <see cref="keepLoaded"/> parameter
 /// is specified.
 /// </summary>
 /// <typeparam name="T">Type of the resource.</typeparam>
 /// <param name="reference">Reference to the resource to load.</param>
 /// <param name="keepLoaded">If true the system will keep the resource loaded even when it goes out of scope.
 ///                          You must call <see cref="Release(ResourceRef)"/> in order to allow the resource to be
 ///                          unloaded (it must be called once for each corresponding load). </param>
 /// <returns>Loaded resource, or null if resource cannot be found.</returns>
 public static T Load <T>(ResourceRef reference, bool keepLoaded = true) where T : Resource
 {
     return((T)Internal_LoadRef(reference, keepLoaded));
 }
Esempio n. 5
0
 private static extern Resource Internal_LoadRef(ResourceRef reference, bool keepLoaded);