// 添加一个依赖资源 protected string AddDependencies(WXResource resource) { string convertedPath = resource.Export(usingPreset); if (convertedPath != "" && convertedPath != null) { dependencies.Add(convertedPath); } return(convertedPath); }
protected override JSONObject ToJSON(WXHierarchyContext context) { List <string> linkSprite = new List <string>(); JSONObject child = new JSONObject(JSONObject.Type.ARRAY); JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); JSONObject layers = new JSONObject(JSONObject.Type.ARRAY); json.AddField("type", getTypeName()); json.AddField("data", data); Avatar avatar = animator.avatar; if ((UnityEngine.Object)avatar != (UnityEngine.Object)null) { AssetImporter importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(avatar.GetInstanceID())); ModelImporter mImporter = importer as ModelImporter; if (mImporter && mImporter.optimizeGameObjects) { WXAvatar converter = new WXAvatar(avatar, gameObject); string avatarPath = converter.Export(context.preset); if (avatarPath != null && avatarPath != "") { data.AddField("avatar", avatarPath); context.AddResource(avatarPath); } } } if (gameObject.GetComponent <Animator>().runtimeAnimatorController != null) { //string controllerId = SaveController(gameObject); WXResource controllerConverter = (WXResource)WXResource.getConverter( gameObject.GetComponent <Animator>().runtimeAnimatorController, gameObject ); string animatorControllerPath = controllerConverter.Export(context.preset); data.AddField("controller", animatorControllerPath); context.AddResource(animatorControllerPath); } data.AddField("cullingMode", (uint)animator.cullingMode); return(json); }
public static void writeGroup(WXResource resource, ExportPreset preset) { try { EditorUtility.DisplayProgressBar( "导出资源", "资源读取中...", 0.33f ); string resourcePath = resource.Export(preset); EditorUtility.DisplayProgressBar( "导出资源", "文件写入中...", 0.66f ); string packageName = WXUtility.GetFileNameFromPath(resourcePath); if (packageName == "") { packageName = "Untitled"; } ExportStore.GenerateResourcePackage( packageName, resourcePath ); } catch (Exception e) { Debug.LogError(e.Message); Debug.LogError(e.StackTrace); } finally { EditorUtility.ClearProgressBar(); } }
private void exportPrefabResource(GameObject go, WXEntity entity) { #if UNITY_2018_4_OR_NEWER GameObject sourceObj = PrefabUtility.GetCorrespondingObjectFromOriginalSource(go); if (preset.is2d) { // Debug.LogError("preset.is2d" + preset.is2d); // Debug.LogError(prefab2dType); // prefabPath WXResource prefabInstance = (WXResource)Activator.CreateInstance(prefab2dType, new object[] { sourceObj, entity.prefabPath, false, false }); AddResource(prefabInstance.Export(preset)); } else { // Debug.LogError("preset.is2d" + preset.is2d); WXPrefab prefab = new WXPrefab(sourceObj, entity.unityAssetPath); AddResource(prefab.Export(preset)); } #else GameObject sourceObj = PrefabUtility.GetPrefabParent(go) as GameObject; if (preset.is2d) { // Debug.LogError("preset.is2d" + preset.is2d); // Debug.LogError(prefab2dType); WXResource prefabInstance = (WXResource)Activator.CreateInstance(prefab2dType, new object[] { sourceObj, entity.prefabPath, false, false }); AddResource(prefabInstance.Export(preset)); // WXNGUITree prefab = new WXNGUITree(sourceObj, entity.prefabPath, false); // AddResource(prefab.Export(preset)); } else { // Debug.LogError("preset.is2d" + preset.is2d); WXPrefab prefab = new WXPrefab(sourceObj, entity.unityAssetPath); AddResource(prefab.Export(preset)); } #endif }
protected override JSONObject ToJSON(WXHierarchyContext context) { List <string> linkSprite = new List <string>(); JSONObject child = new JSONObject(JSONObject.Type.ARRAY); JSONObject json = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); JSONObject layers = new JSONObject(JSONObject.Type.ARRAY); json.AddField("type", getTypeName()); json.AddField("data", data); Avatar avatar = animator.avatar; if ((UnityEngine.Object)avatar != (UnityEngine.Object)null) { WXAvatar converter = new WXAvatar(avatar, gameObject); string avatarPath = converter.Export(context.preset); if (avatarPath != null && avatarPath != "") { data.AddField("avatar", avatarPath); context.AddResource(avatarPath); } } if (gameObject.GetComponent <Animator>().runtimeAnimatorController != null) { //string controllerId = SaveController(gameObject); WXResource controllerConverter = (WXResource)WXResource.getConverter( gameObject.GetComponent <Animator>().runtimeAnimatorController, gameObject ); string animatorControllerPath = controllerConverter.Export(context.preset); data.AddField("controller", animatorControllerPath); context.AddResource(animatorControllerPath); } return(json); }
public ExportErrorReporter setResource(WXResource resource) { this.resource = resource; return(this); }