示例#1
0
 /// <summary> Disposes editor if it contains null targets. </summary>
 /// <param name="editor"> [in,out] The editor to check. </param>
 /// <returns> True if editor was disposed, false if not. </returns>
 public static bool DisposeIfInvalid([NotNull] ref IPreviewableWrapper editor)
 {
     if (!editor.StateIsValid)
     {
         Dispose(ref editor);
         return(true);
     }
     return(false);
 }
示例#2
0
        /// <inheritdoc cref="Dispose(ref IPreviewableWrapper)"/>
        private void DisposeInternal(ref IPreviewableWrapper previewable)
        {
                        #if DEV_MODE && DEBUG_DISPOSE
            UnityEngine.Debug.Log("Dispose called for IPreviewableWrapper " + StringUtils.TypeToString(previewable) + " of " + StringUtils.TypeToString(previewable.target) + " (" + StringUtils.ToString(editor.target) + ")");
                        #endif

                        #if DEV_MODE
            UnityEngine.Debug.Assert(previewable != null, "Dispose called for null editor where ReferenceEquals(editor, null)=" + ReferenceEquals(previewable, null));
                        #endif

            var key = previewable.Key;
            if (IsCached(key))
            {
                if (!Platform.IsCompiling && Validate(previewable))
                {
                                        #if DEV_MODE && DEBUG_DISPOSE
                    UnityEngine.Debug.Log("Dispose - Keeping cached IPreviewableWrapper " + StringUtils.TypeToString(editor) + " of " + StringUtils.TypeToString(editor.target) + " (" + StringUtils.ToString(editor.target) + ")");
                                        #endif
                    previewable = null;
                    return;
                }

                                #if DEV_MODE && DEBUG_DISPOSE
                UnityEngine.Debug.Log("Dispose - Removing cached IPreviewableWrapper " + StringUtils.TypeToString(editor) + " of " + StringUtils.TypeToString(editor.target) + " (" + StringUtils.ToString(editor.target) + ")");
                                #endif

                RemoveFromCache(key);
            }

                        #if DEV_MODE && DEBUG_DISPOSE
            UnityEngine.Debug.Log("Dispose - Disposing IPreviewableWrapper " + previewable);
                        #endif

            previewable.Dispose();
            previewable = null;
        }
示例#3
0
 /// <summary> Checks that the given editor has no null target objects. </summary>
 /// <param name="editor"> The editor to check. This cannot be null. </param>
 /// <returns> True if editor is valid, false if has null targets. </returns>
 public static bool Validate([NotNull] IPreviewableWrapper previewable)
 {
     return(previewable.StateIsValid);
 }
示例#4
0
 /// <summary>
 /// Handles disposing the previewable. If previewable is not found in cache, or has invalid state, destroys it, otherwise just sets it null.
 /// </summary>
 /// <param name="previewable"> [in,out] The IPreviewableWrapper to Dispose. This should not be null when the method is called. </param>
 public static void Dispose(ref IPreviewableWrapper previewable)
 {
     Instance().DisposeInternal(ref previewable);
 }
示例#5
0
 public static bool RemoveFromCache(IPreviewableWrapper previewableWrapper)
 {
     return(RemoveFromCache(previewableWrapper.Key));
 }
示例#6
0
 public static bool IsCached(IPreviewableWrapper previewableWrapper)
 {
     return(IsCached(previewableWrapper.Key));
 }