Beispiel #1
0
        /// <summary>
        /// 绘制对象的预览图
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="uObj"></param>
        public static void DrawAssetPreview(Rect rect, UnityObject uObj)
        {
            var previewTexture = AssetPreview.GetAssetPreview(uObj);

            if (previewTexture != null)
            {
                EditorGUI.LabelField(rect, GUIContent.none, EGUIStyles.GetTextureStyle(previewTexture));
            }
        }
        public static void DrawAssetPreview(UnityObject uObj, float width = 64, float height = 64)
        {
            var previewTexture = AssetPreview.GetAssetPreview(uObj);

            if (previewTexture != null)
            {
                width  = Mathf.Clamp(width, 0, previewTexture.width);
                height = Mathf.Clamp(height, 0, previewTexture.height);
                var previewOptions = new GUILayoutOption[]
                {
                    UnityEngine.GUILayout.MaxWidth(width),
                    UnityEngine.GUILayout.MaxHeight(height),
                };
                Rect rect = EditorGUILayout.GetControlRect(true, height, previewOptions);
                EditorGUI.LabelField(rect, GUIContent.none, EGUIStyles.GetTextureStyle(previewTexture));
            }
        }