public EditorWrapper(Editor previewEditor, Object[] targets) { editor = previewEditor; key = new PreviewableKey(previewEditor.GetType(), targets); #if DEV_MODE && DEBUG_CONSTRUCTOR Debug.Log("EditorWrapper(" + previewEditor + ", " + StringUtils.ToString(targets) + ") with key=" + key.GetHashCode()); #endif }
public ObjectPreviewWrapper(ObjectPreview setObjectPreview, Object[] setTargets, PreviewableKey setKey) { objectPreview = setObjectPreview; key = setKey; type = setObjectPreview.GetType(); targets = setTargets; previewTitle = setObjectPreview.GetPreviewTitle(); objectPreview.Initialize(setTargets); }
/// <inheritdoc cref="GetPreviews(Editor, Object[], ref List<IPreviewableWrapper>)"/> private void GetPreviewsInternal(Editor gameObjectOrAssetEditor, Object[] targets, ref List <IPreviewableWrapper> results) { results.Add(new EditorWrapper(gameObjectOrAssetEditor, targets)); var target = targets[0]; if (target == null) { return; } var targetType = target.GetType(); List <Type> previewableTypes; if (!previewablesByTarget.TryGetValue(targetType, out previewableTypes)) { return; } for (int n = previewableTypes.Count - 1; n >= 0; n--) { var previewableType = previewableTypes[n]; var key = new PreviewableKey(previewableType, targets); IPreviewableWrapper cachedWrapper; if (cachedPreviews.TryGetValue(key, out cachedWrapper)) { cachedWrapper.OnBecameActive(targets); results.Add(cachedWrapper); } else { results.Add(CreatePreviewableWrapper(previewableType, targets, key)); } } #if DEV_MODE && DEBUG_GET_PREVIEWS UnityEngine.Debug.Log(StringUtils.ToColorizedString("GetPreviews(editor=", gameObjectOrAssetEditor.GetType(), ", target=", editorTargetType, ", results=", results, ")")); #endif }
public EditorWrapper(Editor previewEditor) { editor = previewEditor; key = new PreviewableKey(editor.GetType(), editor.targets); }
private static ObjectPreviewWrapper CreatePreviewableWrapper([NotNull] Type previewableType, Object[] targets, PreviewableKey key) { var previewable = Activator.CreateInstance(previewableType) as ObjectPreview; return(new ObjectPreviewWrapper(previewable, targets, key)); }
public static bool RemoveFromCache(PreviewableKey key) { return(Instance().cachedPreviews.Remove(key)); }
public static bool IsCached(PreviewableKey editor) { return(Instance().cachedPreviews.ContainsKey(editor)); }