﻿using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;

namespace JLGames.RocketDriver.Editor.Infra
{
//    [CustomPropertyDrawer(typeof(EditorAssetIndexInfo))]
    public class EditorAssetIndexInfoDrawer : PropertyDrawer
    {
        /// <summary>
        /// UIElements实现
        /// </summary>
        /// <param name="property"></param>
        /// <returns></returns>
        public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            var container = new VisualElement();
            container.Add(new PropertyField(property.FindPropertyRelative("AssetName")));
            container.Add(new PropertyField(property.FindPropertyRelative("UnityPath")));
            container.Add(new PropertyField(property.FindPropertyRelative("Guid")));
            container.Add(new PropertyField(property.FindPropertyRelative("FileId")));
            container.Add(new PropertyField(property.FindPropertyRelative("SpriteId")));
            return container;
        }

        /// <summary>
        /// IMGUI实现
        /// </summary>
        /// <param name="position"></param>
        /// <param name="property"></param>
        /// <param name="label"></param>
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.PropertyField(position, property.FindPropertyRelative("AssetName"));
            EditorGUILayout.PropertyField(property.FindPropertyRelative("UnityPath"));
            EditorGUILayout.PropertyField(property.FindPropertyRelative("Guid"));
            EditorGUILayout.PropertyField(property.FindPropertyRelative("FileId"));
            EditorGUILayout.PropertyField(property.FindPropertyRelative("SpriteId"));
        }
    }
}