MatchClassNames.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEditor;
  5. using UnityEditor.VersionControl;
  6. using UnityEngine;
  7. using UnityEngine.Analytics;
  8. using WebSocketSharp;
  9. namespace DCGO.Tools.Repair
  10. {
  11. public class MatchClassNames : MonoBehaviour
  12. {
  13. [MenuItem("Window/DCGO/Repair/MatchClassNames")]
  14. static void FixEntityCardIndex()
  15. {
  16. Dictionary<string,string> classNameDictionary = new Dictionary<string,string>();
  17. string path = "Assets/CardBaseEntity/";
  18. if (Selection.assetGUIDs.Length != 0)
  19. path = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
  20. Debug.Log($"ASSET PATH: {path}");
  21. List<CEntity_Base> List = GetAsset.LoadAll<CEntity_Base>(path).ToList();
  22. string assetName = "";
  23. //Locate All mismatched classNames
  24. foreach (CEntity_Base card in List)
  25. {
  26. assetName = card.CardSpriteName.Replace("-", "_");
  27. if (assetName == card.name)
  28. {
  29. Debug.Log($"Matches already: {card.name}");
  30. continue;
  31. }
  32. Debug.Log($"Name Change: {card.name} - {assetName}");
  33. AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(card), assetName);
  34. EditorUtility.SetDirty(card);
  35. }
  36. Debug.Log($"DONE");
  37. return;
  38. }
  39. }
  40. }