using System.Collections.Generic; using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine; using UnityEngine.SceneManagement; using System.Linq; using System; public class AttachCardData : MonoBehaviour { [MenuItem("Window/Attach/AttachCardData")] static void Attach_CardData() { List List = GetAsset.LoadAll("Assets/CardBaseEntity/"); List UnimplementedCardIDs = new List() { "BT10-084", "BT12-044" }; foreach (GameObject obj in Selection.gameObjects) { if (obj.GetComponent() != null) { ContinuousController CCtrl = obj.GetComponent(); CCtrl.CardList = new CEntity_Base[] { }; CCtrl.SortedCardList = new CEntity_Base[] { }; List cEntity_Bases = new List(); foreach (CEntity_Base cEntity_Base in List) { if (UnimplementedCardIDs.Contains(cEntity_Base.CardID)) { continue; } if (String.IsNullOrEmpty(cEntity_Base.CardSpriteName)) { continue; } cEntity_Bases.Add(cEntity_Base); } EditorGUI.BeginChangeCheck(); CCtrl.CardList = DeckData.SortedCardPoolList(cEntity_Bases).ToArray(); cEntity_Bases.Sort((a, b) => a.CardIndex - b.CardIndex); CCtrl.SortedCardList = cEntity_Bases.ToArray(); if (EditorGUI.EndChangeCheck()) { var scene = SceneManager.GetActiveScene(); EditorSceneManager.MarkSceneDirty(scene); } Debug.Log($"card:{CCtrl.CardList.ToList().Map(cEntity_Base => cEntity_Base.CardID).Distinct().ToList().Count}kinds"); return; } } } }