12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using System;
- using UnityEditor;
- using UnityEngine;
- namespace XGame.Editor.Asset.Addressable
- {
- public abstract class AddressableAssetEntry : IComparable
- {
- public enum EntryType
- {
- None = 0,
- Fold,
- File
- }
- /// <summary>
- /// 路径
- /// </summary>
- public string Path { private set; get; }
- /// <summary>
- /// 显示的名字
- /// </summary>
- public string ShowName { private set; get; }
- /// <summary>
- /// 文件夹开启标志
- /// </summary>
- public bool IsFoldout { set; get; }
- public virtual EntryType EnType => EntryType.None;
- private AddressableAssetEntry parent;
- public AddressableAssetEntry Parent
- {
- set
- {
- parent = value;
- OnSetParent();
- }
- get => parent;
- }
- protected AddressableAssetEntry(string path)
- {
- Path = path;
- ShowName = System.IO.Path.GetFileNameWithoutExtension(path);
- }
- public void GUI()
- {
- bool hasParent = parent != null;
- if (hasParent)
- {
- EditorGUILayout.BeginHorizontal();
- GUILayout.Space(10);
- }
- OnGUI();
- if (hasParent)
- {
- EditorGUILayout.EndHorizontal();
- }
- }
- public void Clear()
- {
- OnClear();
- }
- protected abstract void OnSetParent();
- protected abstract void OnGUI();
- protected abstract void OnClear();
- public int CompareTo(object obj)
- {
- int result = 0;
- if (obj is AddressableAssetEntry compare)
- {
- result = EnType - compare.EnType;
- if (result == 0)
- {
- result = string.Compare(ShowName, compare.ShowName, StringComparison.OrdinalIgnoreCase);
- }
- }
- return result;
- }
- }
- }
|