AdjustSetSpecificCardIndex.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 = 10352;
  13. int adjustment = 0;
  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. .Filter(x => x.CardIndex >= startingIndex);
  21. foreach (CEntity_Base card in List)
  22. {
  23. Debug.Log($"{card.name}: {card.CardIndex} - {startingIndex}");
  24. card.CardIndex = startingIndex - adjustment;
  25. EditorUtility.SetDirty(card);
  26. startingIndex++;
  27. }
  28. Debug.Log("Fixed all card index in CardBaseEntity");
  29. return;
  30. }
  31. }
  32. }