// export private void Export() { Instance = this; _canceled = false; try { // load config json GLexConfig.Load(); // create exporter and setup paths Type exporterType = Type.GetType((string)GLexConfig.ExporterType, true); Exporter exporter = Activator.CreateInstance(exporterType) as Exporter; exporter.SetupPaths(_exportDirectory); // recurse scene graph mData = new GLexData(); if (!GLexConfig.ExportSceneGameObject) { mData.Scene = new GLexScene(mData); mData.Project = new GooProject(mData, PlayerSettings.productName); } for (int i = 0; i < _toExport.Count; ++i) { if (!RecurseSceneGraph(_toExport[i].transform, null)) { return; } } EditorUtility.DisplayProgressBar("Preparing for export", string.Empty, 0); mData.PrepareForExport(); // export if (exporter.Export(mData)) { if (!exporter.WithoutErrors) { Debug.LogError("One or more errors occurred during export: " + exporter.Error); } else { EditorUtility.ClearProgressBar(); EditorUtility.DisplayDialog("Export successful!", "Exported to " + GLexConfig.BasePath, "ok"); Debug.Log("Exported to " + GLexConfig.BasePath); } } else { Debug.LogError("User cancelled export"); } } finally { EditorUtility.ClearProgressBar(); } }
public GLexGameObject(GameObject gameObject, GLexData data) : base() { mGameObject = gameObject; mComponents = new List <GLexComponent>(); _glexData = data; _keystring = NamesUtil.GenerateUniqueId(); // if (Settings == null) { // AddSettings(); // } }
public GLexGameObject(GameObject gameObject, GLexData data) : base() { mGameObject = gameObject; mComponents = new List<GLexComponent>(); _glexData = data; _keystring = NamesUtil.GenerateUniqueId(); // if (Settings == null) { // AddSettings(); // } }
public GLexData() { Instance = this; GLexMaterial.Reset(); GLexMesh.Reset(); GLexTexture.Reset(); GLexShader.Reset(); GLexSkinnedMeshRenderer.Reset(); GLexBone.Reset(); GLexAnimation.Reset(); GLexAnimationClip.Reset(); GLexAnimationState.Reset(); GooSkybox.Reset(); GLexAudioSource.Reset(); GooSkeleton.Reset(); mGLexGameObjects = new List <GLexGameObject>(); mGLexTopGameObjects = new List <GLexGameObject>(); mGLexComponents = new List <GLexComponent>(); }
// export private void Export() { Instance = this; _canceled = false; try { // load config json GLexConfig.Load(); // create exporter and setup paths Type exporterType = Type.GetType((string)GLexConfig.ExporterType, true); Exporter exporter = Activator.CreateInstance(exporterType) as Exporter; exporter.SetupPaths(_exportDirectory); // recurse scene graph mData = new GLexData(); if (!GLexConfig.ExportSceneGameObject) { mData.Scene = new GLexScene(mData); mData.Project = new GooProject(mData, PlayerSettings.productName); } for (int i = 0; i < _toExport.Count; ++i) { if (!RecurseSceneGraph(_toExport[i].transform, null)) { return; } } EditorUtility.DisplayProgressBar("Preparing for export", string.Empty, 0); mData.PrepareForExport(); // export if (exporter.Export(mData)) { if (!exporter.WithoutErrors) { Debug.LogError("One or more errors occurred during export: " + exporter.Error); } else { EditorUtility.ClearProgressBar(); EditorUtility.DisplayDialog("Export successful!", "Exported to " + GLexConfig.BasePath, "ok"); Debug.Log("Exported to " + GLexConfig.BasePath); } } else { Debug.LogError("User cancelled export"); } } finally { EditorUtility.ClearProgressBar(); } }
private void RestoreSceneAfterExport() { selectedTransforms.Clear(); GLexData.RemoveAddedSettings(); }
public virtual bool Export(GLexData data) { Debug.Log("Exporter.Export: Please override the Export method"); return(true); }
public GooProject(GLexData data, string name) { _glexData = data; _name = name; }
public virtual bool Export(GLexData data) { Debug.Log("Exporter.Export: Please override the Export method"); return true; }
public GLexScene(GLexData data) : base() { _glexData = data; _environment = new GooEnvironment(this); }
public GLexScene(GLexData data) : base() { _glexData = data; _environment = new GooEnvironment(this); }
public GooProject(GLexData data, string name) { _glexData = data; _name = name; }
public override bool Export(GLexData data) { /* * // Uncomment this to re-enable settings validation. * // Right now it's just obnoxious and the results aren't used for anything. * if (!ValidateSettings()) { * return; * } */ _exportedFiles.Clear(); _exportQueue.Clear(); if (GLex.Instance.CleanDirectory) { AddExportAction("Cleaning output directory", () => CleanDirectory(GLexConfig.BasePath)); } // save project // AddExportAction("Exporting project", delegate { // StringTemplate projectTemplate = LoadTemplate("project"); // projectTemplate.SetAttribute("project", data.Project); // AddExportedJson(projectTemplate, data.Project.Id); // }); // environment AddExportAction("Exporting environment", delegate { var environment = data.Scene.Environment; var envTemplate = LoadTemplate("environment"); envTemplate.SetAttribute("env", environment); AddExportedJson(envTemplate, environment.Id); }); // save scene AddExportAction("Exporting scene", delegate { StringTemplate scene = LoadTemplate("scene"); scene.SetAttribute("entities", EnumerableUtil.Indexify(data.TopGameObjects)); scene.SetAttribute("scene", data.Scene); scene.SetAttribute("exporter", this); AddExportedJson(scene, data.Scene.Id); }); // save postfx AddExportAction("Exporting postfx", delegate { StringTemplate postfx = LoadTemplate("posteffects"); // postfx.SetAttribute("entities", EnumerableUtil.Indexify(data.GameObjects)); // postfx.SetAttribute("scene", data.Scene); // postfx.SetAttribute("exporter", this); AddExportedJson(postfx, "403694af24c54b6c93434ee2f8ce6f0b.posteffects"); }); // save entities foreach (var goConverter in data.GameObjects) { var exportedObject = goConverter; // Copy the reference AddExportAction(goConverter.Name, delegate { var entityTemplate = LoadTemplate("entity"); entityTemplate.SetAttribute("entity", exportedObject); entityTemplate.SetAttribute("components", exportedObject.Components); AddExportedJson(entityTemplate, exportedObject.Id); }); } // save materials foreach (var matConverter in data.Materials) { var exportedObject = matConverter; // Copy the reference AddExportAction(matConverter.Name, delegate { StringTemplate material = LoadTemplate("material"); material.SetAttribute("material", exportedObject); AddExportedJson(material, exportedObject.Id); }); } // save textures foreach (GLexTexture texConverter in data.Textures) { var exportedObject = texConverter; // Copy the reference AddExportAction(texConverter.Name, delegate { exportedObject.SaveBinaryData(); var texture = LoadTemplate("texture"); texture.SetAttribute("texture", exportedObject); AddExportedJson(texture, exportedObject.Id); }); } // save sounds foreach (var soundConverter in data.SoundClips) { var exportedObject = soundConverter; // Copy the reference AddExportAction(soundConverter.Name, delegate { exportedObject.SaveBinaryData(); var soundTemplate = LoadTemplate("sound"); soundTemplate.SetAttribute("sound", exportedObject); AddExportedJson(soundTemplate, exportedObject.Id); }); } // save meshes if (GLex.Instance.ExportMeshes) { var binary = new GooBinary(); var converters = new List <GooBinaryMesh>(); foreach (var glexMesh in data.Meshes) { converters.Add(new GooBinaryMesh(glexMesh)); } for (int i = 0; i < converters.Count; ++i) { var meshConverter = converters[i]; AddExportAction(meshConverter.Name + " (binary)", delegate { meshConverter.AddToBinary(binary); }); } AddExportAction("Saving mesh binaries", () => binary.SaveToDisk()); for (int i = 0; i < converters.Count; ++i) { foreach (var subMeshProxy in converters[i].SubMeshes) { var proxyCopy = subMeshProxy; AddExportAction(converters[i].Name + "#" + subMeshProxy.SubMeshIndex, delegate { StringTemplate mesh = LoadTemplate("mesh"); mesh.SetAttribute("mesh", proxyCopy); AddExportedJson(mesh, proxyCopy.Id); }); } } } // save skeletons ExportObjects(GooSkeleton.AllSkeletons, "skeleton", "skeleton"); // save animations ExportObjects(data.Animations, "animation", "animation"); // save states ExportObjects(data.AnimationStates, "animationState", "state"); // save clips var clipBinary = new GooBinary(); foreach (var glexClip in data.AnimationClips) { var exportedClip = glexClip; AddExportAction(exportedClip.Name, delegate { exportedClip.AddToBinary(clipBinary); }); } AddExportAction("Saving clip binaries", () => clipBinary.SaveToDisk()); foreach (var glexClip in data.AnimationClips) { var exportedClip = glexClip; AddExportAction(exportedClip.Name, delegate { var template = LoadTemplate("animationClip"); template.SetAttribute("clip", exportedClip); AddExportedJson(template, exportedClip.Id); }); } // skyboxes ExportObjects(GooSkybox.AllSkyboxes, "skybox", "skybox"); // Do it all if (!ExecuteExportActions()) { return(false); } // send to create or bundle if (GLex.Instance.UploadToCreate) { if (SaveExportedFilesAsBundle()) { SendToCreate(); } else { return(false); } } else if (GLex.Instance.BundleProject) { if (!SaveExportedFilesAsBundle()) { return(false); } else { // string directory = Path.Combine (GLexConfig.BasePath, "root.bundle"); // string zip = Path.Combine (GLexConfig.BasePath, GLexSceneSettings.FileName + ".zip"); string directory = GLexConfig.BasePathWithoutSceneName; string zip = GLexConfig.BasePathWithoutSceneName + "/bundle_" + GLexSceneSettings.FileName + ".zip"; Compress(directory, zip); } } else { SaveExportedFiles(); } // remove temporary components foreach (Component component in mComponentsToRemoveAfterExport) { UnityEngine.Object.DestroyImmediate(component); } foreach (var obj in mObjectsToRemoveAfterExport) { UnityEngine.Object.DestroyImmediate(obj); } return(true); }