ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Unity场景导出GLTF格式的文件方法

2021-07-15 09:02:49  阅读:1748  来源: 互联网

标签:Assets 导出 name UnityGLTF Unity using Runtime GLTF


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

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

2、打开UnityGLTF项目

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

Assets\UnityGLTF\Runtime\Scripts\Extensions\SchemaExtensions.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?)

Assets\UnityGLTF\Runtime\Scripts\GLTFSceneExporter.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?)

Assets\UnityGLTF\Runtime\Scripts\GLTFSceneExporter.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库放在了UnityGLTF\UnityGLTF\Assets\UnityGLTF\Runtime\Plugins目录下了。

 

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

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

Assets\UnityGLTF\Tests\Runtime\GLTFAssetGeneratorTests.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文件以及bin文件。

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

参考文献:

https://github.com/KhronosGroup/UnityGLTF

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

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

标签:Assets,导出,name,UnityGLTF,Unity,using,Runtime,GLTF
来源: https://blog.csdn.net/grace_yi/article/details/118751033

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有