Exemplo n.º 1
0
        public static void initPluginDlls()
        {
            List <string> dlls = FileHelper.FindFile("Assets/Plugins/", new string[] { "*.dll" });

            SaveGUIDMap saveGuidMap = Get();

            bool hasNew = false;

            foreach (string dllItem in dlls)
            {
                string dllPath = dllItem.Replace(Application.dataPath, "Assets");
                Dictionary <int, string> dic = FileIDUtil.getAllFileIDByDll(dllPath);
                if (dic == null)
                {
                    continue;
                }
                foreach (int key in dic.Keys)
                {
                    if (saveGuidMap.addFileID(key.ToString(), dic[key], false))
                    {
                        hasNew = true;
                    }
                }
            }

            if (hasNew)
            {
                saveGuidMap.save();
            }
        }
Exemplo n.º 2
0
        private static void getMapping(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                return;
            }
            string[] list = content.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);

            if (list.Length < 1)
            {
                return;
            }

            FileIDUtil.clearRouter();
            string[] keyValuePair;
            string   key;
            string   value;

            foreach (string item in list)
            {
                if (string.IsNullOrEmpty(item))
                {
                    continue;
                }
                keyValuePair = item.Split('=');

                key   = keyValuePair[0].Trim();
                value = keyValuePair[1].Trim();

                /*int index = value.IndexOf('\\');
                 * if (index!=-1)
                 * {
                 *  value=value.Substring(0, index - 1);
                 * }*/

                FileIDUtil.registerRouter(key, value);
            }
        }
Exemplo n.º 3
0
        public void doSingle(GameObject go, bool isSingle = true)
        {
            bool hasChange = false;
            bool hasError  = false;

            string           v = AssetDatabase.GetAssetPath(go);
            PrefabFileRefGet prefabFileRefGet = PrefabFileRefGet.get(v);

            Selection.activeObject     = null;
            Selection.activeGameObject = null;

            foreach (FileRefVO vo in prefabFileRefGet.fileRefs)
            {
                string guidPath = vo.guidPath;

                if (vo.isMonoScript)
                {
                    if (string.IsNullOrEmpty(guidPath))
                    {
                        guidPath = map.getGUIDPath(vo.guid);
                    }

                    if (string.IsNullOrEmpty(guidPath))
                    {
                        continue;
                    }

                    //map.getGUIDPath(vo.guid);
                    string className;

                    if (guidPath.EndsWith(".dll"))
                    {
                        className = map.getFileIDName(vo.fileID);
                        if (string.IsNullOrEmpty(className))
                        {
                            className = FileIDUtil.getFileNameByFileID(int.Parse(vo.fileID));
                        }
                        string outDllPath;
                        Type   classType = FileIDUtil.getTypeByName(className, out outDllPath);
                        if (classType != null && outDllPath != guidPath)
                        {
                            vo.fileIDName = null;
                            vo.fileID     = null;
                        }
                    }
                    else
                    {
                        className = Path.GetFileNameWithoutExtension(guidPath);
                    }

                    if (className == null)
                    {
                        continue;
                    }

                    ///没有变化;
                    if (className == vo.fileIDName)
                    {
                        continue;
                    }

                    string firstChar = className[0].ToString().ToUpper();
                    if (firstChar != className[0].ToString())
                    {
                        className = firstChar + className.Substring(1);
                    }

                    string dllPath;
                    Type   type = FileIDUtil.getTypeByName(className, out dllPath);
                    if (type == null)
                    {
                        className = FileIDUtil.getRouter(className);
                        type      = FileIDUtil.getTypeByName(className, out dllPath);
                    }

                    if (type != null)
                    {
                        string guid   = AssetDatabase.AssetPathToGUID(dllPath);
                        string fileID = FileIDUtil.Compute(type).ToString();
                        if (string.IsNullOrEmpty(guid) == false && string.IsNullOrEmpty(fileID) == false &&
                            fileID != vo.fileID)
                        {
                            vo.guid     = guid;
                            vo.fileID   = fileID;
                            vo.isChange = true;
                        }
                    }
                    else if (string.IsNullOrEmpty(vo.guidPath) == false)
                    {
                        if (vo.fileID != "11500000")
                        {
                            //不在dll里面的类
                            vo.fileID   = "11500000";
                            vo.isChange = true;
                        }
                    }
                    else
                    {
                        Debug.LogError("找不到类: " + className + ", 请配置一个转换路径");
                        hasError = true;
                        continue;
                    }
                }
                else if (string.IsNullOrEmpty(vo.guidPath))
                {
                    string path = map.getGUIDPath(vo.guid);
                    if (string.IsNullOrEmpty(path))
                    {
                        continue;
                    }

                    string guid = AssetDatabase.AssetPathToGUID(path);
                    if (string.IsNullOrEmpty(guid))
                    {
                        path = FileIDUtil.getRouter(path);
                        guid = AssetDatabase.AssetPathToGUID(path);
                    }

                    if (string.IsNullOrEmpty(guid))
                    {
                        Debug.LogError(path + ":找不到路径,请配置一个转换路径");
                        hasError = true;
                        continue;
                    }

                    if (guid != vo.guid)
                    {
                        vo.guid     = guid;
                        vo.isChange = true;
                    }
                }

                if (vo.isChange)
                {
                    hasChange = true;
                }
            }

            if (hasError)
            {
                return;
            }

            if (hasChange)
            {
                prefabFileRefGet.replace();
                //AssetDatabase.Refresh();
            }
            else if (isSingle)
            {
                EditorUtility.DisplayDialog("找回失败", "只能手动找回,\n\n如果复杂可找程序员看是否有其它方法找回!!!", "好的");
            }
        }
Exemplo n.º 4
0
        private void getKeyValuePair(string item, string header)
        {
            int indexL = item.IndexOf("{");
            int indexR = item.IndexOf("}");

            if (indexL == -1 || indexR == -1)
            {
                return;
            }
            string context = item.Substring(indexL + 1, indexR - indexL - 1);

            if (string.IsNullOrEmpty(context))
            {
                return;
            }

            string[] propertys = context.Split(',');
            string[] keyValues;

            string key;
            string value;
            Dictionary <string, string> keyValuePair = new Dictionary <string, string>();

            foreach (string property in propertys)
            {
                if (string.IsNullOrEmpty(property))
                {
                    continue;
                }

                keyValues = property.Split(':');

                if (keyValues.Length != 2)
                {
                    continue;
                }

                key   = keyValues[0].Trim();
                value = keyValues[1].Trim();
                keyValuePair.Add(key, value);
            }

            if (keyValuePair.ContainsKey("guid") && keyValuePair.ContainsKey("fileID"))
            {
                FileRefVO vo = new FileRefVO();
                vo.guid      = keyValuePair["guid"];
                vo.fileID    = keyValuePair["fileID"];
                vo.type      = int.Parse(keyValuePair["type"]);
                vo.lineValue = item;

                item            = item.Replace(vo.guid, "$1");
                vo.templeteLine = item.Replace(vo.fileID, "$0");

                vo.guidPath = AssetDatabase.GUIDToAssetPath(vo.guid);
                if (item.StartsWith("m_Script:"))
                {
                    if (vo.guidPath.EndsWith(".dll"))
                    {
                        FileIDUtil.getAllFileIDByDll(vo.guidPath);
                        vo.fileIDName = FileIDUtil.getFileNameByFileID(int.Parse(vo.fileID));
                    }
                    vo.isMonoScript = true;
                }
                fileRefs.Add(vo);
            }
        }