Exporting models support
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityGLTF;
|
||||
|
||||
|
||||
public class ModelExporter
|
||||
{
|
||||
public static string RetrieveTexturePath(UnityEngine.Texture texture)
|
||||
{
|
||||
string m_Path = Application.dataPath;
|
||||
var path = m_Path + "/../unknown/" + texture.name; ;
|
||||
return path;
|
||||
}
|
||||
|
||||
public static void Export(Transform[] transforms, string sceneName)
|
||||
{
|
||||
var exportOptions = new UnityGLTF.ExportOptions { TexturePathRetriever = RetrieveTexturePath };
|
||||
var exporter = new GLTFSceneExporter(transforms, exportOptions);
|
||||
|
||||
string m_Path = Application.dataPath;
|
||||
|
||||
string path = m_Path + "/../Exported/" + sceneName;
|
||||
|
||||
var resultFile = GLTFSceneExporter.GetFileName(path, sceneName, ".gltf");
|
||||
|
||||
exporter.SaveGLTFandBin(path, sceneName);
|
||||
|
||||
}
|
||||
|
||||
public static void exportModel(GameObject gameobj)
|
||||
{
|
||||
string sceneName = gameobj.name;
|
||||
Transform[] rootTransforms = new Transform[] { gameobj.transform };
|
||||
|
||||
Export(rootTransforms, sceneName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf3b5b616874ba1479b187dd881b2ebb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -31,7 +31,7 @@ public class TextureExporter
|
||||
{
|
||||
string m_Path = Application.dataPath;
|
||||
|
||||
string savePath = m_Path + "/../Texture2D/" + gameobj.name + "/";
|
||||
string savePath = m_Path + "/../Exported/" + gameobj.name + "/Texture2D/";
|
||||
|
||||
if (!Directory.Exists(savePath))
|
||||
{
|
||||
|
||||
@@ -1310,10 +1310,12 @@ public class UmaViewerUI : MonoBehaviour
|
||||
MessageScrollRect.verticalNormalizedPosition = 0;
|
||||
}
|
||||
|
||||
public void ExportTextures()
|
||||
public void ExportModel()
|
||||
{
|
||||
if (Builder.CurrentUMAContainer)
|
||||
{
|
||||
//TextureExporter.exportAllTexture(Builder.CurrentUMAContainer.gameObject);
|
||||
ModelExporter.exportModel(Builder.CurrentUMAContainer.gameObject);
|
||||
TextureExporter.exportAllTexture(Builder.CurrentUMAContainer.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"GUID:800597811bcc5d848b15e12807d6de45",
|
||||
"GUID:d60799ab2a985554ea1a39cd38695018",
|
||||
"GUID:fd1d627189c561043911a07470238b9c",
|
||||
"GUID:145e2572884581c48a08acf566c1a1d6"
|
||||
"GUID:145e2572884581c48a08acf566c1a1d6",
|
||||
"GUID:18d18f811ba286c49814567a3cfba688"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
Reference in New Issue
Block a user