/// <summary> /// Exports ANY Game Object given to it. Will provide a dialog and return the path of the newly exported file /// </summary> /// <returns>The path of the newly exported FBX file</returns> /// <param name="gameObj">Game object to be exported</param> /// <param name="copyMaterials">If set to <c>true</c> copy materials.</param> /// <param name="copyTextures">If set to <c>true</c> copy textures.</param> /// <param name="oldPath">Old path.</param> public static string ExportGameObject(GameObject gameObj, bool exportColliders, bool copyMaterials, bool copyTextures, string oldPath = null) { if (gameObj == null) { EditorUtility.DisplayDialog("Object is null", "Please select any GameObject to Export to FBX", "Okay"); return(null); } string newPath = GetNewPath(gameObj, oldPath); if (newPath != null && newPath.Length != 0) { bool isSuccess = FBXExporter.ExportGameObjToFBX(gameObj, newPath, exportColliders, copyMaterials, copyTextures); if (isSuccess) { return(newPath); } else { EditorUtility.DisplayDialog("Warning", "The extension probably wasn't an FBX file, could not export.", "Okay"); } } return(null); }
/// <summary> /// Exports ANY Game Object given to it. Will provide a dialog and return the path of the newly exported file /// </summary> /// <returns>The path of the newly exported FBX file</returns> /// <param name="gameObj">Game object to be exported</param> /// <param name="copyMaterials">If set to <c>true</c> copy materials.</param> /// <param name="copyTextures">If set to <c>true</c> copy textures.</param> /// <param name="oldPath">Old path.</param> public static string ExportGameObject(List <GameObject> gameObjects, bool copyMaterials, bool copyTextures, string oldPath = null) { foreach (var gameObj in gameObjects) { if (gameObj == null) { EditorUtility.DisplayDialog("Object is null", "Please select any GameObject to Export to FBX", "Okay"); return(null); } } // Get folder path string newPath = GetNewPath(oldPath); if (newPath == null) { return(null); } foreach (var gameObject in gameObjects) { var fileName = newPath + "/" + gameObject.name + ".fbx"; if (fileName != null && fileName.Length != 0) { bool isSuccess = FBXExporter.ExportGameObjToFBX(gameObject, fileName, copyMaterials, copyTextures); if (!isSuccess) { EditorUtility.DisplayDialog("Warning", "The extension probably wasn't an FBX file, could not export.", "Okay"); } } } return(newPath); }