AdjustSetSpecificCardIndex.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 = 3300;
  13. string path = "Assets/CardBaseEntity/";
  14. if (Selection.assetGUIDs.Length != 0)
  15. path = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
  16. Debug.Log($"ASSET PATH: {path}");
  17. List<CEntity_Base> List = GetAsset.LoadAll<CEntity_Base>(path)
  18. .OrderBy(x => x.name.Substring(x.name.LastIndexOf("-")+1,3)).ToList();
  19. foreach (CEntity_Base card in List)
  20. {
  21. Debug.Log($"{card.name}: {card.CardIndex} - {startingIndex}");
  22. card.CardIndex = startingIndex;
  23. EditorUtility.SetDirty(card);
  24. startingIndex++;
  25. }
  26. Debug.Log("Fixed all card index in CardBaseEntity");
  27. return;
  28. }
  29. }
  30. }