#unity/白日梦/代码缓存 ``` cs using System.Collections.Generic; using System.IO; using LightUtility; using Sirenix.OdinInspector; using Sirenix.OdinInspector.Editor; using UnityEditor; using UnityEngine; namespace DMMLogic.Common.ToolsModule.ImportResourceArtModule { public class ImportResourceArtToolEditor : OdinEditorWindow { #region 数据类 private string m_InGameEmotionPath = "Assets/ResourcesRaw/Mainland/Tables/Client/IngameEmotion.csv"; private IdBasedList IngameEmotionInfo; private int IntTreviewIndex = 1; private int IntTreviewSearch = 1; private enum InOutType //局内外 数据类型 { None, Out, In } private enum Lv //LOD等级 { None, NoLv, Lv0, Lv1, Lv2, Lv3, Lv4 } private enum Part //身体部位 { None, NoPart, Head, Hand, Body, Shoe } private Lv currentLv = Lv.None; //当前等级 private InOutType currentInOutType = InOutType.None; //当前类型 private Part currentPart = Part.None; //当前身体部位 private List ResourceType = new List { " #特效", " #动作" }; #endregion #region 导入器界面 private static ImportResourceArtToolEditor _importResourceArtToolEditor; public static ImportResourceArtToolEditor GetImportResourceArtToolEditor { get { return _importResourceArtToolEditor; } } /// /// 外部导入 /// [MenuItem("GameObject/特效工具")] public static void ImportOutSide() { ShowWindow(); } /// /// 内部导入 /// [MenuItem("Assets/特效工具")] public static void ImportInSide() { ShowWindow(); } public static void ShowWindow() { if (_importResourceArtToolEditor == null) { _importResourceArtToolEditor = GetWindow(typeof(ImportResourceArtToolEditor)) as ImportResourceArtToolEditor; _importResourceArtToolEditor.Init(); } _importResourceArtToolEditor.Show(); } [TitleGroup("菜单")] [TabGroup("菜单/特效","导入",true)] [ValueDropdown("TreeViewOfInts", ExpandAllMenuItems = false),LabelText("选一个资源→")] public int InterTreeView = 1; private ValueDropdownList TreeViewOfInts = new ValueDropdownList { { "请输入", 1 }, }; [OnValueChanged("OnChoosePrefab")] [TabGroup("菜单/特效","查找",true,1)] [ValueDropdown("TreeViewOfSearch", ExpandAllMenuItems = false),LabelText("查一个资源→")] public int InterTreeSearch = 1; private ValueDropdownList TreeViewOfSearch = new ValueDropdownList { {"请查找", 1}, }; private bool toggle = true; #region 局内外 [DisableIf("@toggle")] [VerticalGroup("菜单/特效/导入/first")] [ShowIf("@InterTreeView > 1")] [Button("选择局内外",ButtonSizes.Large)] public void ChooseInOut() { } [DisableIf("@toggle")] [VerticalGroup("菜单/特效/查找/first",0)] [ShowIf("@InterTreeSearch > 1")] [Button("搜索结果",ButtonSizes.Large)] public void SearchOut() { } [VerticalGroup("菜单/特效/查找/first",1)] [ShowIf("@InterTreeSearch > 1")] public List SearchList; private void OnChoosePrefab() { if (InterTreeSearch > 1) { if (SearchList == null) { SearchList = new List(); } string[] files = Directory.GetFiles( $"{Application.dataPath}/../Assets/BundleResources/CommonRegion/InGame/Skins/Emotions/Thief_12/PropPrefabs/", "*.prefab"); SearchList.Clear(); for (int i = 0; i < files.Length; i++) { GameObject obj = AssetDatabase.LoadAssetAtPath( "Assets/BundleResources/CommonRegion/InGame/Skins/Emotions/Thief_12/PropPrefabs/" + Path.GetFileName(files[i])); if (obj != null) { if (!SearchList.Contains(obj) && obj.name.Contains("03016052")) { SearchList.Add(obj); } } } } } [ShowIf("@InterTreeView > 1 && currentInOutType != InOutType.In")] [HorizontalGroup("菜单/特效/导入/InOutChoose")] [Button("局内",ButtonSizes.Gigantic),GUIColor(0,1,0)] public void YetInside() { currentInOutType = InOutType.In; } [ShowIf("@InterTreeView > 1 && currentInOutType == InOutType.In")] [HorizontalGroup("菜单/特效/导入/InOutChoose")] [Button("已选 局内",ButtonSizes.Gigantic),GUIColor(1,0.2f,0)] public void AleadyInside() { currentInOutType = InOutType.None; } [ShowIf("@InterTreeView > 1 && currentInOutType != InOutType.Out")] [HorizontalGroup("菜单/特效/导入/InOutChoose/right")] [Button("局外",ButtonSizes.Gigantic),GUIColor(0,1,0)] public void YetOutSide() { currentInOutType = InOutType.Out; } [ShowIf("@InterTreeView > 1 && currentInOutType == InOutType.Out")] [HorizontalGroup("菜单/特效/导入/InOutChoose/right")] [Button("已选 局外",ButtonSizes.Gigantic),GUIColor(1,0.2f,0)] public void AleadyOutSide() { currentInOutType = InOutType.None; } #endregion #region 分级 [DisableIf("@toggle")] [VerticalGroup("菜单/特效/导入/second")] [ShowIf("@currentInOutType != InOutType.None")] [Button("选择分级",ButtonSizes.Large)] public void ChooseLevel() { } [ShowIf("@currentInOutType != InOutType.None && currentLv != Lv.NoLv")] [HorizontalGroup("菜单/特效/导入/LvChoose")] [Button("不分级",ButtonSizes.Gigantic),GUIColor(0,1,0)] public void YetLvNo() { currentLv = Lv.NoLv; } [ShowIf("@currentInOutType != InOutType.None && currentLv == Lv.NoLv")] [HorizontalGroup("菜单/特效/导入/LvChoose")] [Button("已选 不分级",ButtonSizes.Gigantic),GUIColor(1,0.2f,0)] public void AleadyLvNo() { currentLv = Lv.None; } [ShowIf("@currentInOutType != InOutType.None && currentLv != Lv.Lv0")] [HorizontalGroup("菜单/特效/导入/LvChoose/lv0")] [Button("零级",ButtonSizes.Gigantic),GUIColor(0,1,0)] public void YetLvZero() { currentLv = Lv.Lv0; } [ShowIf("@currentInOutType != InOutType.None && currentLv == Lv.Lv0")] [HorizontalGroup("菜单/特效/导入/LvChoose/lv0")] [Button("已选 零级",ButtonSizes.Gigantic),GUIColor(1,0.2f,0)] public void AleadyLvZero() { currentLv = Lv.None; } [ShowIf("@currentInOutType != InOutType.None && currentLv != Lv.Lv1")] [HorizontalGroup("菜单/特效/导入/LvChoose/lv1")] [Button("一级",ButtonSizes.Gigantic),GUIColor(0,1,0)] public void YetLvOne() { currentLv = Lv.Lv1; } [ShowIf("@currentInOutType != InOutType.None && currentLv == Lv.Lv1")] [HorizontalGroup("菜单/特效/导入/LvChoose/lv1")] [Button("已选 一级",ButtonSizes.Gigantic),GUIColor(1,0.2f,0)] public void AleadyLvOne() { currentLv = Lv.None; } [ShowIf("@currentInOutType != InOutType.None && currentLv != Lv.Lv2")] [HorizontalGroup("菜单/特效/导入/LvChoose/lv2")] [Button("二级",ButtonSizes.Gigantic),GUIColor(0,1,0)] public void YetLvTwo() { currentLv = Lv.Lv2; } [ShowIf("@currentInOutType != InOutType.None && currentLv == Lv.Lv2")] [HorizontalGroup("菜单/特效/导入/LvChoose/lv2")] [Button("已选 二级",ButtonSizes.Gigantic),GUIColor(1,0.2f,0)] public void AleadyLvTwo() { currentLv = Lv.None; } [ShowIf("@currentInOutType != InOutType.None && currentLv != Lv.Lv3")] [HorizontalGroup("菜单/特效/导入/LvChoose/lv3")] [Button("三级",ButtonSizes.Gigantic),GUIColor(0,1,0)] public void YetLvThree() { currentLv = Lv.Lv3; } [ShowIf("@currentInOutType != InOutType.None && currentLv == Lv.Lv3")] [HorizontalGroup("菜单/特效/导入/LvChoose/lv3")] [Button("已选 三级",ButtonSizes.Gigantic),GUIColor(1,0.2f,0)] public void AleadyLvThree() { currentLv = Lv.None; } [ShowIf("@currentInOutType != InOutType.None && currentLv != Lv.Lv4")] [HorizontalGroup("菜单/特效/导入/LvChoose/lv4")] [Button("四级",ButtonSizes.Gigantic),GUIColor(0,1,0)] public void YetLvFour() { currentLv = Lv.Lv4; } [ShowIf("@currentInOutType != InOutType.None && currentLv == Lv.Lv4")] [HorizontalGroup("菜单/特效/导入/LvChoose/lv4")] [Button("已选 四级",ButtonSizes.Gigantic),GUIColor(1,0.2f,0)] public void AleadyLvFour() { currentLv = Lv.None; } #endregion // #region 部位 // // [DisableIf("@toggle")] // [ShowIf("@currentLv != Lv.None")] // [Button("选择部位",ButtonSizes.Large)] // public void ChoosePart() // { // // } // // [ShowIf("@currentLv != Lv.None && currentPart != Part.NoPart")] // [HorizontalGroup("PartChoose")] // [Button("无",ButtonSizes.Gigantic),GUIColor(0,1,0)] // public void YetPartNo() // { // currentPart = Part.NoPart; // } // // [ShowIf("@currentLv != Lv.None && currentPart == Part.NoPart")] // [HorizontalGroup("PartChoose")] // [Button("已选 无",ButtonSizes.Gigantic),GUIColor(1,0.2f,0)] // public void AleadyPartNo() // { // currentPart = Part.None; // } // // [ShowIf("@currentLv != Lv.None && currentPart != Part.Head")] // [HorizontalGroup("PartChoose/head")] // [Button("头",ButtonSizes.Gigantic),GUIColor(0,1,0)] // public void YetHead() // { // currentPart = Part.Head; // } // // [ShowIf("@currentLv != Lv.None && currentPart == Part.Head")] // [HorizontalGroup("PartChoose/head")] // [Button("已选 头",ButtonSizes.Gigantic),GUIColor(1,0.2f,0)] // public void AleadyHead() // { // currentPart = Part.None; // } // // [ShowIf("@currentLv != Lv.None && currentPart != Part.Hand")] // [HorizontalGroup("PartChoose/hand")] // [Button("手",ButtonSizes.Gigantic),GUIColor(0,1,0)] // public void YetHand() // { // currentPart = Part.Hand; // } // // [ShowIf("@currentLv != Lv.None && currentPart == Part.Hand")] // [HorizontalGroup("PartChoose/hand")] // [Button("已选 手",ButtonSizes.Gigantic),GUIColor(1,0.2f,0)] // public void AleadyHand() // { // currentPart = Part.None; // } // // [ShowIf("@currentLv != Lv.None && currentPart != Part.Body")] // [HorizontalGroup("PartChoose/body")] // [Button("身体",ButtonSizes.Gigantic),GUIColor(0,1,0)] // public void YetBody() // { // currentPart = Part.Body; // } // // [ShowIf("@currentLv != Lv.None && currentPart == Part.Body")] // [HorizontalGroup("PartChoose/body")] // [Button("已选 身体",ButtonSizes.Gigantic),GUIColor(1,0.2f,0)] // public void AleadyBody() // { // currentPart = Part.None; // } // // [ShowIf("@currentLv != Lv.None && currentPart != Part.Shoe")] // [HorizontalGroup("PartChoose/Shoe")] // [Button("腿部",ButtonSizes.Gigantic),GUIColor(0,1,0)] // public void YetShoe() // { // currentPart = Part.Shoe; // } // // [ShowIf("@currentLv != Lv.None && currentPart == Part.Shoe")] // [HorizontalGroup("PartChoose/Shoe")] // [Button("已选 腿部",ButtonSizes.Gigantic),GUIColor(1,0.2f,0)] // public void AleadyShoe() // { // currentPart = Part.None; // } // // #endregion [ShowIf("@currentLv != Lv.None")] [VerticalGroup("菜单/特效/导入/third")] [Button("导入", ButtonSizes.Gigantic)] public void GetIn() { List files = new List { "12121", "sasdafa" }; PushEditor _PushEditor = new PushEditor(files); _PushEditor = GetWindow(typeof(PushEditor)) as PushEditor; _PushEditor.Show(); } #endregion #region 导入器 方法体 /// /// 初始化 /// public void Init() { CSVReader.LoadCSVTable(File.ReadAllText(m_InGameEmotionPath), out IngameEmotionInfo, 1); string ResourceTypeString = (Selection.assetGUIDs == null || Selection.assetGUIDs.Length == 0) ? ResourceType[1] : ResourceType[0]; for (int i = 0; i < IngameEmotionInfo.Count; i++) { IntTreviewIndex = IntTreviewIndex + 1; TreeViewOfInts.Add(IngameEmotionInfo[i].Lan_Name + " #编号:" + IngameEmotionInfo[i].Config + ResourceTypeString, IntTreviewIndex); IntTreviewSearch = IntTreviewSearch + 1; TreeViewOfSearch.Add(IngameEmotionInfo[i].Lan_Name + " #编号:" + IngameEmotionInfo[i].Config + ResourceTypeString, IntTreviewSearch); } } #endregion } } ```