mbunch_kascope 1 éve
szülő
commit
64c8cc3c3b

+ 30 - 5
Assets/Editor/Fixing Scripts/CleanUpClassName.cs

@@ -1,11 +1,7 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
-using UnityEditor.SceneManagement;
 using UnityEditor;
 using UnityEngine;
-using UnityEngine.SceneManagement;
-using DCGO.CardEntities;
 
 namespace DCGO.Tools.Repair{
     public class CleanUpClassName : MonoBehaviour
@@ -60,7 +56,36 @@ namespace DCGO.Tools.Repair{
             }
         }
 
-        
+        [MenuItem("Window/DCGO/Repair/Convert Entity Class Names")]
+        static void ConvertEntityClassNames()
+        {
+            string path = "Assets/CardBaseEntity/";
+
+            if (Selection.assetGUIDs.Length != 0)
+                path = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
+
+            List<CEntity_Base> List = GetAsset.LoadAll<CEntity_Base>(path);
+
+            string cardList = "";
+            int count = 0;
+
+            foreach (CEntity_Base card in List)
+            {
+                string cardID = card.CardID.Replace("-", "_");
+
+                if(!String.IsNullOrEmpty(card.CardEffectClassName))
+                    card.CardEffectClassName = card.CardEffectClassName.Substring(card.CardEffectClassName.IndexOf("_") + 1);
+                EditorUtility.SetDirty(card);
+                Debug.Log($"{card.CardSpriteName.Replace("-", "_")} - {cardID} - {card.CardEffectClassName}");
+                AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(card), card.CardSpriteName.Replace("-", "_"));
+                count++;
+                EditorUtility.SetDirty(card);
+            }
+
+            Debug.Log("Cards using another class:\n" + cardList);
+            Debug.Log($"Fixed all class names in CardBaseEntity: {count}");
+            return;
+        }
     }
 }
 

+ 141 - 0
Assets/Editor/Fixing Scripts/MatchClassNames.cs

@@ -0,0 +1,141 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.Analytics;
+
+namespace DCGO.Tools.Repair
+{
+    public class MatchClassNames : MonoBehaviour
+    {
+        [MenuItem("Window/DCGO/Repair/MatchClassNames")]
+        static void FixEntityCardIndex()
+        {
+            Dictionary<string,string> classNameDictionary = new Dictionary<string,string>();
+            string path = "Assets/CardBaseEntity/";
+
+            if (Selection.assetGUIDs.Length != 0)
+                path = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
+
+            Debug.Log($"ASSET PATH: {path}");
+
+            List<CEntity_Base> List = GetAsset.LoadAll<CEntity_Base>(path)
+                .OrderBy(x => x.name.Substring(x.name.LastIndexOf("-")+1, 2)).ToList();
+
+            string className = "";
+            string editList = "Asset Name - Original Class - New Class \n";
+            int foundCount = 0;
+
+            //Locate All mismatched classNames
+            foreach (CEntity_Base card in List)
+            {
+                className = "";
+
+                if (String.IsNullOrEmpty(card.CardEffectClassName))
+                {
+                    Debug.Log($"Class Name Empty: {card.name}");
+                    continue;
+                }
+
+                if (!card.CardEffectClassName.Contains(card.CardID.Replace("-", "_")))
+                {
+                    Debug.Log($"Using Alternate Card: {card.name}");
+                    continue;
+                }
+
+                className = FixCharactersInClassName($"{card.CardID}");
+
+                if (className == card.CardEffectClassName)
+                {
+                    Debug.Log($"Matches already: {card.name}");
+                    continue;
+                }
+
+                editList += $"{card.name} - {card.CardEffectClassName} - {className}\n";
+
+                if (!classNameDictionary.ContainsKey(className))
+                    classNameDictionary.Add(className, card.CardEffectClassName);
+
+                /*if (!card.name.Contains("_P"))
+                {
+                    if (String.IsNullOrEmpty(card.CardEffectClassName))
+                        continue;
+
+                    if (!card.CardEffectClassName.Contains(card.CardID.Replace("-", "_")))
+                        continue;
+
+                    className = card.CardEffectClassName;
+                    continue;
+                }
+                
+
+                if (!card.CardEffectClassName.Equals(className))
+                {
+                    if (!classNameDictionary.ContainsKey(className))
+                        classNameDictionary.Add(className, card.CardEffectClassName);
+
+                    //Debug.Log($"{card.name}: {card.CardIndex} - {card.CardEffectClassName} != {className}");
+                }*/
+
+
+                //card.CardEffectClassName = className;
+            }
+
+
+
+            /*foreach (string key in classNameDictionary.Keys)
+            {
+                List<CEntity_Base> filtered = List.Filter(x => x.CardEffectClassName == key).ToList();
+
+                foreach (CEntity_Base card in filtered)
+                {
+                    
+                    //card.CardEffectClassName = classNameDictionary[key];
+                    //EditorUtility.SetDirty(card);
+                }
+                    
+
+                Debug.Log($"Filtered Count: {filtered.Count}");
+            }*/
+            //Debug.Log($"{key} - {classNameDictionary[key]}");
+            Debug.Log(editList);
+            Debug.Log($"DONE: found {classNameDictionary.Keys.Count}");
+            return;
+
+            string FixCharactersInClassName(string str)
+            {
+                string name = str;
+
+                name = FixCharactersInName(name);
+
+                name = name
+                    .Replace("-", "_")
+                    .Replace(".", "")
+                    .Replace("'", "")
+                    .Replace(",","")
+                    .Replace("&", "And")
+                    .Replace("(", "")
+                    .Replace(")", "");
+
+                return name;
+            }
+
+            //Parse ScriptableObject Name
+            string FixCharactersInName(string str)
+            {
+                string name = str;
+
+                name = name
+                    .Replace(" ", "")
+                    .Replace(":", "")
+                    .Replace("?", "")
+                    .Replace("!", "")
+                    .Replace("<", "")
+                    .Replace(">", "");
+
+                return name;
+            }
+        }
+    }
+}

+ 11 - 0
Assets/Editor/Fixing Scripts/MatchClassNames.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 3525c4ed3729f9d4aa2dd7309b26f468
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: