首页 文章

在运行时将对象导入Unity3d / iOS VR程序

提问于
浏览
1

我有一个概念性问题,可能正在咆哮错误的树 . 我对用于编写VR应用程序的Cardboard / Unity3d / iOS管道很感兴趣 . 我正在尝试制作一个非常基本的STL查看器 . 我想做的是将STL文件(可能是iCloud)导入应用程序以供查看 .

我正在学习Unity中的资产包作为将对象导入程序的方法 . 这个问题是它们必须在运行时之前准备好并具有特定的引用 .

有没有办法在运行时将STL文件导入Unity而无需事先创建资产包?如果没有,有没有人知道可用软件/管道的组合来完成这项任务?我特别喜欢纸板框架,但似乎支持iOS你必须使用Unity .

任何/所有指导赞赏 . 谢谢 .

1 回答

  • 1

    要将您的STL文件提取到Unity,有WWW类:http://docs.unity3d.com/ScriptReference/WWW.html

    // on iOS, persistent data path is the "Documents" application folder that you can access through iTunes to put STL files in if you build your application wit hthe "Application uses iTunes file sharing" option in XCode
    WWW www1 = new WWW(string.Format("file:///{0}/{1}", Application.persistentDataPath, FileName));
    
    // simple URL on the Internet works too
    WWW www2 = new WWW(string.Format("http://{0}/{1}", FilePath, FileName));
    

    您必须编写STL解析器的代码 . 有很多,但STL是一个非常简单的格式,你应该没有任何困难编写自己的 . 然后你创建你的网格:http://docs.unity3d.com/ScriptReference/Mesh.html

    获得网格后,将MeshRenderer组件添加到任何游戏对象,然后将网格对准它:http://docs.unity3d.com/ScriptReference/MeshRenderer.html

相关问题