Пример #1
0
        public static void ProcessUIViewConfig()
        {
            string prefabPath = UtilityHelper.ConvertToObsPath(PrefabPath);

            string[] allUIPrefab = Directory.GetFiles(
                prefabPath,
                "*.prefab",
                SearchOption.TopDirectoryOnly)
                                   .Where(
                file => file.EndsWith(".prefab") && file.ToLower().Contains("uiview_")).ToArray();

            List <string> newConfigs = new List <string>();
            int           count      = 0;

            foreach (var item in allUIPrefab)
            {
                string fileName = Path.GetFileNameWithoutExtension(item);
                string soPath   = UtilityHelper.ConvertToObsPath(string.Format("{0}/{1}.asset", OutputPath, fileName));
                ++count;
                if (!File.Exists(soPath))
                {
                    //不存在这个so,创建新的
                    SO_UIViewConfig newConfig = ScriptableObject.CreateInstance <SO_UIViewConfig>();
                    newConfig.assetName = fileName;
                    AssetDatabase.CreateAsset(newConfig, string.Format("{0}/{1}.asset", OutputPath, fileName));
                    newConfigs.Add(string.Format(string.Format("(新建) {0}. {1} -> {2} ", count, fileName, OutputPath)));
                    EditorUtility.SetDirty(newConfig);
                }
                else
                {
                    newConfigs.Add(string.Format(string.Format("(已存在) {0}. {1} -> {2} ", count, fileName, OutputPath)));
                }
            }
            if (newConfigs.Count > 0)
            {
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                //显示界面
                UIViewConfigHelperWindow.Show("刷新界面配置文件", newConfigs, new Rect(200, 200, 600, newConfigs.Count * 22 + 50));
            }
            else
            {
                EditorUtility.DisplayDialog("Complete", "There isn't any view config need to be created.", "OK");
            }
        }
Пример #2
0
        public static void Show(string title, List <string> contents, Rect rect)
        {
            UIViewConfigHelperWindow window = GetWindow <UIViewConfigHelperWindow>(title, true);

            UIViewConfigHelperWindow.contents = contents;
            UIViewConfigHelperWindow.rect     = rect;

            window.minSize = rect.size;
            window.maxSize = rect.size;

            if (UIViewConfigHelperWindow.contents == null || UIViewConfigHelperWindow.contents.Count == 0)
            {
                return;
            }

            window.position = rect;
            window.Show(true);
        }