Пример #1
0
    //创建目录信息
    static private DirectoryInfo CreatDirectory()
    {
        DirectoryInfo directiory = new DirectoryInfo(Application.dataPath + "/" + UITemplatePath.GetTemplatePrefabPath().Replace("Assets/", ""));

        if (!directiory.Exists)
        {
            directiory.Create();
            Refresh();
        }
        return(directiory);
    }
Пример #2
0
    //对象是否在Project面板
    static private bool IsTemplatePrefabInInProjectView(GameObject go)
    {
        string path = AssetDatabase.GetAssetPath(go);

        if (!string.IsNullOrEmpty(path))
        {
            return(path.Contains(UITemplatePath.GetTemplatePrefabPath()));
        }
        else
        {
            return(false);
        }
    }
Пример #3
0
    //读取配置文件
    public static void ReadRetainConfig()
    {
        retainDict.Clear();

        DirectoryInfo TheFolder = new DirectoryInfo(UITemplatePath.GetRetainProperyPath());

        //遍历文件
        foreach (FileInfo nextFile in TheFolder.GetFiles())
        {
            if (nextFile.FullName.EndsWith(".txt"))
            {
                string       path = nextFile.FullName;
                StreamReader sr   = new StreamReader(path, Encoding.Default);
                string       line;

                string        typeString   = "";
                List <string> propertyList = new List <string>();

                int index = 0;
                while ((line = sr.ReadLine()) != null)
                {
                    if (index == 0)
                    {
                        typeString = line;
                    }
                    else
                    {
                        propertyList.Add(line);
                    }

                    ++index;
                }

                retainDict[typeString] = propertyList;

                sr.Close();
                sr.Dispose();
            }
        }
    }
Пример #4
0
    static private bool TrySearchPrefab(string headName, out List <GameObject> searchList)
    {
        List <GameObject> prefabs = new List <GameObject>();
        bool trySearch            = false;

        foreach (string forder in UITemplatePath.GetUIPrefabPathList())
        {
            //找出对应目录下的所有prefab
            DirectoryInfo directiory = new DirectoryInfo(Application.dataPath + "/" + forder.Replace("Assets/", ""));
            FileInfo[]    infos      = directiory.GetFiles("*.prefab", SearchOption.AllDirectories);

            //遍历
            for (int i = 0; i < infos.Length; i++)
            {
                FileInfo   file   = infos[i];
                GameObject prefab = AssetDatabase.LoadAssetAtPath <GameObject>(file.FullName.Substring(file.FullName.IndexOf("Assets")));

                Debug.Log("开始查找" + prefab.name);
                if (prefab.GetComponentsInChildren <XUITemplate>(true).Length > 0)
                {
                    GameObject    go        = Instantiate <GameObject>(prefab);
                    XUITemplate[] templates = go.GetComponentsInChildren <XUITemplate>(true);
                    foreach (XUITemplate template in templates)
                    {
                        //查找出ID一样的,加入队列
                        if (template.headName == headName && template.index == "0" && !prefabs.Contains(prefab))
                        {
                            prefabs.Add(prefab);
                        }
                    }
                    GameObject.DestroyImmediate(go);
                }
            }
        }

        searchList = prefabs;
        return(!trySearch);
    }