AttachCardData.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System.Collections.Generic;
  2. using UnityEditor;
  3. using UnityEditor.SceneManagement;
  4. using UnityEngine;
  5. using UnityEngine.SceneManagement;
  6. using System.Linq;
  7. using System;
  8. public class AttachCardData : MonoBehaviour
  9. {
  10. [MenuItem("Window/Attach/AttachCardData")]
  11. static void Attach_CardData()
  12. {
  13. List<CEntity_Base> List = GetAsset.LoadAll<CEntity_Base>("Assets/CardBaseEntity/");
  14. List<string> UnimplementedCardIDs = new List<string>() { "BT10-084", "BT12-044" };
  15. foreach (GameObject obj in Selection.gameObjects)
  16. {
  17. if (obj.GetComponent<ContinuousController>() != null)
  18. {
  19. ContinuousController CCtrl = obj.GetComponent<ContinuousController>();
  20. CCtrl.CardList = new CEntity_Base[] { };
  21. CCtrl.SortedCardList = new CEntity_Base[] { };
  22. List<CEntity_Base> cEntity_Bases = new List<CEntity_Base>();
  23. foreach (CEntity_Base cEntity_Base in List)
  24. {
  25. if (UnimplementedCardIDs.Contains(cEntity_Base.CardID))
  26. {
  27. continue;
  28. }
  29. if (String.IsNullOrEmpty(cEntity_Base.CardSpriteName))
  30. {
  31. continue;
  32. }
  33. cEntity_Bases.Add(cEntity_Base);
  34. }
  35. EditorGUI.BeginChangeCheck();
  36. CCtrl.CardList = DeckData.SortedCardPoolList(cEntity_Bases).ToArray();
  37. cEntity_Bases.Sort((a, b) => a.CardIndex - b.CardIndex);
  38. CCtrl.SortedCardList = cEntity_Bases.ToArray();
  39. if (EditorGUI.EndChangeCheck())
  40. {
  41. var scene = SceneManager.GetActiveScene();
  42. EditorSceneManager.MarkSceneDirty(scene);
  43. }
  44. Debug.Log($"card:{CCtrl.CardList.ToList().Map(cEntity_Base => cEntity_Base.CardID).Distinct().ToList().Count}kinds");
  45. return;
  46. }
  47. }
  48. }
  49. }