Exemple #1
0
        protected override void DoExport()
        {
            Scene      gameScene = SceneManager.GetActiveScene();
            string     path      = gameScene.path;
            WXUGUITree converter = new WXUGUITree(objectRoot, path, true, true);

            PresetUtil.writeGroup(converter, this);
        }
        // 导出一个资源
        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);
                //    }
                //}

                WXUGUITree wxPrefab = new WXUGUITree(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);
            }
        }
Exemple #3
0
        protected override void DoExport()
        {
            GameObject prefabRoot = (GameObject)Selection.activeObject;

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

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