首页 > 编程知识 正文

unity glb格式,unity场景文件后缀

时间:2023-05-04 02:12:20 阅读:209561 作者:1580

最近需要在Unity中解析GLTF文件,以及能够导出Unity的场景信息。经过查询,最后决定使用UnitGLTF这个开源库。

1、首选下载代码,git clone https://github.com/KhronosGroup/UnityGLTF.git

2、打开UnityGLTF项目

3、打开项目之后,选择Samples下面的一个场景,在Console有超多的错误信息。

AssetsUnityGLTFRuntimeScriptsExtensionsSchemaExtensions.cs(229,52): error CS0246: The type or namespace name 'GLTF' could not be found (are you missing a using directive or an assembly reference?)

AssetsUnityGLTFRuntimeScriptsGLTFSceneExporter.cs(54,11): error CS0246: The type or namespace name 'BufferId' could not be found (are you missing a using directive or an assembly reference?)

AssetsUnityGLTFRuntimeScriptsGLTFSceneExporter.cs(55,11): error CS0246: The type or namespace name 'GLTFBuffer' could not be found (are you missing a using directive or an assembly reference?)

看这些错误信息,看是没有引入GLTF库。

4、编译GLTFSerialization,最后生成的dll库放在了UnityGLTFUnityGLTFAssetsUnityGLTFRuntimePlugins目录下了。

 

5、关闭,再次重新打UnityGLTF,看看是否正常了呢?咦,怎么还有错误呢?

首选需要把plugins目录下的uap10.0.10586给删除掉,否则会有重复的库。

AssetsUnityGLTFTestsRuntimeGLTFAssetGeneratorTests.cs(3,7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

还有一些错误,是因为Tests引用不到GLTF库,我们也把Tests给删除掉。

这样就把所有的错误给清理掉了。

 

6、导出场景的GLTF文件,可以看到可以导出一个gltf json文件以及糊涂的皮卡丘文件。

GLTF相关的可以用这张图片来描述。

参考文献:

https://github.com/KhronosGroup/UnityGLTF

https://github.com/KhronosGroup/glTF/tree/master/specification/2.0

https://github.khronos.org/glTF-Sample-Viewer-Release/

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。