AttachCardData.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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> UnimplementedCardSpriteNames = new List<string>() { "P-147" };
  15. List<string> DebugCardSpriteNames = new List<string>() { "EX5-070_P1" };
  16. foreach (GameObject obj in Selection.gameObjects)
  17. {
  18. if (obj.GetComponent<ContinuousController>() != null)
  19. {
  20. ContinuousController CCtrl = obj.GetComponent<ContinuousController>();
  21. CCtrl.CardList = new CEntity_Base[] { };
  22. CCtrl.SortedCardList = new CEntity_Base[] { };
  23. List<CEntity_Base> cEntity_Bases = new List<CEntity_Base>();
  24. foreach (CEntity_Base cEntity_Base in List)
  25. {
  26. if (UnimplementedCardSpriteNames.Contains(cEntity_Base.CardSpriteName))
  27. {
  28. Debug.Log(cEntity_Base.CardID);
  29. continue;
  30. }
  31. if (String.IsNullOrEmpty(cEntity_Base.CardSpriteName))
  32. {
  33. continue;
  34. }
  35. if (DebugCardSpriteNames.Contains(cEntity_Base.CardSpriteName))
  36. {
  37. Debug.Log(cEntity_Base.CardID);
  38. }
  39. cEntity_Bases.Add(cEntity_Base);
  40. }
  41. EditorGUI.BeginChangeCheck();
  42. CCtrl.CardList = DeckData.SortedCardPoolList(cEntity_Bases).ToArray();
  43. cEntity_Bases.Sort((a, b) => a.CardIndex - b.CardIndex);
  44. CCtrl.SortedCardList = cEntity_Bases.ToArray();
  45. if (EditorGUI.EndChangeCheck())
  46. {
  47. var scene = SceneManager.GetActiveScene();
  48. EditorSceneManager.MarkSceneDirty(scene);
  49. }
  50. Debug.Log($"card:{CCtrl.CardList.ToList().Map(cEntity_Base => cEntity_Base.CardID).Distinct().ToList().Count}kinds");
  51. return;
  52. }
  53. }
  54. }
  55. }