protected override void DoExport()
        {
            // GameObject prefabRoot = (GameObject) Selection.activeObject;

            GameObject[] prefabRoots = Selection.gameObjects;

            Scene gameScene = SceneManager.GetActiveScene();

            if (!gameScene.isDirty || gameScene.isDirty && EditorUtility.DisplayDialog("提示", "检测到当前场景未保存,导出会自动进行保存场景,是否要继续导出", "导出", "暂不导出"))
            {
                string path = gameScene.path;

                EditorSceneManager.SaveScene(gameScene, path);

                foreach (GameObject prefabRoot in prefabRoots)
                {
                    WXNGUITree converter = new WXNGUITree(
                        prefabRoot,
                        AssetDatabase.GetAssetPath(WXUtility.GetPrefabSource(prefabRoot)),
                        (this.exportConfigs as NGUIExportConfig).exportAsScene
                        );

                    PresetUtil.writeGroup(converter, this /*, (string)(configs.ContainsKey("exportPath") ? configs["exportPath"] : "")*/);
                }
            }
        }
Пример #2
0
        // 导出一个资源
        private void DequeueAndExport(int maxCount)
        {
            string guid      = exportQueue.Dequeue();
            string assetPath = AssetDatabase.GUIDToAssetPath(guid);

            EditorUtility.DisplayProgressBar(
                "资源导出",
                assetPath,
                (float)(maxCount - exportQueue.Count - 1) / maxCount
                );

            // gameObject
            if (AssetDatabase.GetMainAssetTypeAtPath(assetPath) == typeof(GameObject))
            {
                GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(
                    assetPath,
                    AssetDatabase.GetMainAssetTypeAtPath(assetPath)
                    );
                // prefab
                // 忘了为什么要加这句判断了,资源管理器里的prefab理论上这里返回都是null
                if (WXUtility.GetPrefabSource(prefab))
                {
                    DequeueAndExport(maxCount);
                    return;
                }


                // 资源管理器里的prefab,GetPrefabSource是null,这里就要实例化之后再取。
                prefab = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
                Selection.activeObject    = prefab;
                prefab.transform.position = Vector3.zero;
                prefab.SetActive(true);
                //RichText.StaticTextCreator[] staicTextCreators = prefabRoot.GetComponentsInChildren<RichText.StaticTextCreator>();
                //if (staicTextCreators != null && staicTextCreators.Length > 0)
                //{
                //    for (int k = 0; k < staicTextCreators.Length; k++)
                //    {
                //        RichText.StaticTextCreator stc = staicTextCreators[k];
                //        stc.ParseStaticText(true);
                //    }
                //}

                WXNGUITree wxPrefab = new WXNGUITree(prefab, assetPath, false);
                PresetUtil.writeGroup(wxPrefab, this /*, (string)(configs.ContainsKey("exportPath") ? configs["exportPath"] : "")*/);

                UnityEngine.Object.DestroyImmediate(prefab);
            }

            if (exportQueue.Count == 0)
            {
                EditorUtility.ClearProgressBar();
            }
            else
            {
                DequeueAndExport(maxCount);
            }
        }
Пример #3
0
        protected override void DoExport()
        {
            Scene  gameScene = SceneManager.GetActiveScene();
            string path      = gameScene.path;

            EditorSceneManager.SaveScene(gameScene, path);

            WXNGUITree converter = new WXNGUITree(objectRoot, path, true, true);

            PresetUtil.writeGroup(converter, this);
        }
        protected override void DoExport()
        {
            GameObject prefabRoot = (GameObject)Selection.activeObject;

            Scene  gameScene = SceneManager.GetActiveScene();
            string path      = gameScene.path;

            EditorSceneManager.SaveScene(gameScene, path);

            WXNGUITree converter = new WXNGUITree(
                prefabRoot,
                AssetDatabase.GetAssetPath(WXUtility.GetPrefabSource(prefabRoot)),
                (this.exportConfigs as NGUIExportConfig).exportAsScene
                );

            PresetUtil.writeGroup(converter, this /*, (string)(configs.ContainsKey("exportPath") ? configs["exportPath"] : "")*/);
        }