示例#1
0
 private static void LoadPrefab(string folderPath, Action <GameObject> doSomething)
 {
     if (!Directory.Exists(folderPath))
     {
         return;
     }
     string[] files = Directory.GetFiles(folderPath);
     if (files == null)
     {
         return;
     }
     for (int fileIndex = 0; fileIndex < files.Length; fileIndex++)
     {
         string fullPath = files[fileIndex];
         if (!fullPath.EndsWith(EditorConst.PrefabExtension))
         {
             continue;
         }
         string     projectPath = EditorPath.FullPathToProjectPath(fullPath);
         GameObject prefab      = AssetDatabase.LoadAssetAtPath <GameObject>(projectPath);
         if (prefab == null)
         {
             return;
         }
         doSomething(prefab);
     }
 }
示例#2
0
        private static void AddTempleteUI(EPrefabType prefabType, string prefabName)
        {
            string prefabPath    = prefabType.isNestPrefab() ? EditorPath.NestUIAssetPath : EditorPath.TempleteUIAssetPath;
            string path          = EditorPath.Combine(EditorPath.ProjectPathStart, prefabPath);
            string prefabWithExt = Tool.GetNameWithExtension(prefabName, EditorConst.PrefabExtension);

            m_dicPrefabPath.Add(prefabType, EditorPath.Combine(path, prefabWithExt));
        }
示例#3
0
 public static void LoadAllPrefab(Action <GameObject> doSomething)
 {
     LoadPrefab(EditorPath.TempleteUI, doSomething);
     string[] windowFolders = Directory.GetDirectories(EditorPath.UI);
     if (windowFolders != null)
     {
         for (int index = 0; index < windowFolders.Length; index++)
         {
             string windowPrefabFolder = EditorPath.Combine(windowFolders[index], EditorPath.UIPrefabsFolder);
             LoadPrefab(windowPrefabFolder, doSomething);
         }
     }
     AssetDatabase.SaveAssets();
 }