public static Texture GetPreviewTexture(this ICustomPreview x) { if (x == null) { return(null); } var preview = x.Preview; if (preview == null) { return(null); } #if UNITY_EDITOR return(Sirenix.Utilities.Editor.GUIHelper.GetAssetThumbnail(preview, preview.GetType(), true)); #else return(null); #endif }
protected override void DrawPropertyLayout(GUIContent label) { ICustomPreview item = this.ValueEntry.SmartValue; if (item == null || item.EditorObject == null) { return; } var rect = EditorGUILayout.GetControlRect(label != null, 45); if (label != null) { rect.xMin = EditorGUI.PrefixLabel(rect.AlignCenterY(15), label).xMin; } else { rect = EditorGUI.IndentedRect(rect); } var texture = GUIHelper.GetAssetThumbnail(item.Preview, typeof(Sprite), true); GUI.Label(rect.AddXMin(50).AlignMiddle(16), EditorGUI.showMixedValue ? "-" : item.EditorObject.name); ValueEntry.WeakSmartValue = SirenixEditorFields.UnityPreviewObjectField(rect.AlignLeft(45), item.EditorObject, texture, ValueEntry.BaseValueType); }