AttachCardData.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. 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 (UnimplementedCardSpriteNames.Contains(cEntity_Base.CardSpriteName))
  26. {
  27. Debug.Log(cEntity_Base.CardID);
  28. continue;
  29. }
  30. if (String.IsNullOrEmpty(cEntity_Base.CardSpriteName))
  31. {
  32. continue;
  33. }
  34. cEntity_Bases.Add(cEntity_Base);
  35. }
  36. EditorGUI.BeginChangeCheck();
  37. CCtrl.CardList = DeckData.SortedCardPoolList(cEntity_Bases).ToArray();
  38. cEntity_Bases.Sort((a, b) => a.CardIndex - b.CardIndex);
  39. CCtrl.SortedCardList = cEntity_Bases.ToArray();
  40. if (EditorGUI.EndChangeCheck())
  41. {
  42. var scene = SceneManager.GetActiveScene();
  43. EditorSceneManager.MarkSceneDirty(scene);
  44. }
  45. Debug.Log($"card:{CCtrl.CardList.ToList().Map(cEntity_Base => cEntity_Base.CardID).Distinct().ToList().Count}kinds");
  46. return;
  47. }
  48. }
  49. }
  50. }