AdjustSetSpecificCardIndex.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using UnityEditor;
  4. using UnityEngine;
  5. namespace DCGO.Tools.Repair
  6. {
  7. public class AdjustSetSpecificCardIndex : MonoBehaviour
  8. {
  9. [MenuItem("Window/DCGO/Repair/Fix Entity Card Index")]
  10. static void FixEntityCardIndex()
  11. {
  12. int startingIndex = 3856;
  13. int adjustment = 23;
  14. string path = "Assets/CardBaseEntity/";
  15. if (Selection.assetGUIDs.Length != 0)
  16. path = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
  17. Debug.Log($"ASSET PATH: {path}");
  18. List<CEntity_Base> List = GetAsset.LoadAll<CEntity_Base>(path)
  19. .OrderBy(x => x.name.Substring(x.name.LastIndexOf("-")+1, 2)).ToList();
  20. foreach (CEntity_Base card in List)
  21. {
  22. Debug.Log($"{card.name}: {card.CardIndex} - {startingIndex}");
  23. card.CardIndex = startingIndex - adjustment;
  24. EditorUtility.SetDirty(card);
  25. startingIndex++;
  26. }
  27. Debug.Log("Fixed all card index in CardBaseEntity");
  28. return;
  29. }
  30. }
  31. }