protected override void DoExport() { GameObject[] prefabRoots = Selection.gameObjects; Scene gameScene = SceneManager.GetActiveScene(); if (!gameScene.isDirty || gameScene.isDirty && EditorUtility.DisplayDialog("提示", "检测到当前场景未保存,导出会自动进行保存场景,是否要继续导出", "导出", "暂不导出")) { EditorSceneManager.SaveScene(gameScene, gameScene.path); // foreach (GameObject prefabRoot in prefabRoots) { // WXUtility.TraverseSceneTreeToSave(prefabRoot, gameScene); // } foreach (GameObject prefabRoot in prefabRoots) { WXPrefab converter = new WXPrefab( prefabRoot, AssetDatabase.GetAssetPath(WXUtility.GetPrefabSource(prefabRoot)) ); PresetUtil.writeGroup(converter, this /*, (string)(configs.ContainsKey("exportPath") ? configs["exportPath"] : "")*/); } } }
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"] : "")*/); } } }
// 导出一个资源 private void DequeueAndExport(int maxCount) { if (maxCount == 0) { return; } string guid = exportQueue.Dequeue(); string assetPath = AssetDatabase.GUIDToAssetPath(guid); EditorUtility.DisplayProgressBar( "资源导出", assetPath, (float)(maxCount - exportQueue.Count - 1) / maxCount ); 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); // } //} WXPrefab wxPrefab = new WXPrefab(prefab, assetPath); PresetUtil.writeGroup(wxPrefab, this /*, (string)(configs.ContainsKey("exportPath") ? configs["exportPath"] : "")*/); UnityEngine.Object.DestroyImmediate(prefab); if (exportQueue.Count == 0) { EditorUtility.ClearProgressBar(); } else { DequeueAndExport(maxCount); } }
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"] : "")*/); }
public override bool WillPresetShow() { if (Selection.activeObject == null) { return(false); } try { return(WXUtility.GetPrefabSource(Selection.activeObject)); } catch (Exception e) { return(false); } }
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"] : "")*/); }
protected override void DoExport() { GameObject[] prefabRoots = Selection.gameObjects; foreach (GameObject prefabRoot in prefabRoots) { string path = AssetDatabase.GetAssetPath(WXUtility.GetPrefabSource(prefabRoot)); string[] assetIDs = AssetDatabase.FindAssets("t:Prefab", new string[] { path }); foreach (string guid in assetIDs) { exportQueue.Enqueue(guid); } } DequeueAndExport(exportQueue.Count); }
protected override void DoExport() { GameObject[] prefabRoots = Selection.gameObjects; Scene gameScene = SceneManager.GetActiveScene(); EditorSceneManager.SaveScene(gameScene, gameScene.path); // foreach (GameObject prefabRoot in prefabRoots) { // WXUtility.TraverseSceneTreeToSave(prefabRoot, gameScene); // } foreach (GameObject prefabRoot in prefabRoots) { WXPrefab converter = new WXPrefab( prefabRoot, AssetDatabase.GetAssetPath(WXUtility.GetPrefabSource(prefabRoot)) ); PresetUtil.writeGroup(converter, this /*, (string)(configs.ContainsKey("exportPath") ? configs["exportPath"] : "")*/); } }