Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by nick.mann · Feb 16, 2015 at 11:25 PM · gameobjectinstantiatebyte

How to convert byte[] to GameObject?

I am working on an app that will allow a user to download a FBX model and load it into the app on the iPad. I have successfully written the FBX file to the Application.persistentDataPath on the iPad, and I'm trying to load this new model into the scene.

I am able to read the file as a byte[] and am looking for the best way to Instantiate those bytes into the scene.

If anyone knows how I can to this it would be very helpful.

Thanks in advance!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Bunny83 · Feb 17, 2015 at 02:44 AM

That's not possible since the Unity engine can't read FBX files at runtime. Reading FBX files is an edit-time-feature of the Editor. If you want to load a model at runtime you need to parse the data yourself. FBX is a very complex format and actually needs the SDK from Autodesk.

It's usually easier to use a more simple format like OBJ. There are several OBJ loaders out there.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image nick.mann · Feb 17, 2015 at 01:15 PM 0
Share

Thanks for the advice.

As I'm a bit new to Unity I apologize if the answer to my next question is an obvious one.

I'm going to have a login dialog that, upon successful connection, gives a user a list of models to download and import. When you say 'load a model at runtime' I need to be able to load these models as part of some event trigger, rather than on startup of the app.

Would using OBJ be the best format to do this?

avatar image fafase · Feb 17, 2015 at 01:23 PM 1
Share

You could use AssetBundle if you have pro version.

avatar image Graham-Dunnett ♦♦ · Feb 17, 2015 at 01:45 PM 1
Share

As @fafase says, convert the FBX files into GameObjects, and write these GameObjects into AssetBundles. Then put these AssetBundles onto your server.

avatar image nick.mann · Feb 17, 2015 at 04:11 PM 0
Share

Thanks for all the advice everyone!

I have successfully loaded the FBX model an an AssetBundle. Creating the AssetBundle required the Unity Editor. Is there any way to create an AssetBundle on the fly?

Ideally I would like my web service to be able to take a FBX, generate the assetbundle, then i can download the assetbunble to my device.

avatar image rageingnonsense · Feb 17, 2015 at 10:22 PM 0
Share

What is the end game for displaying the fbx on the device? I ask because to me, it seems like the best way to accomplish what you want to do is to get the FBX SD$$anonymous$$, use it to read the fbx file, then create a new game object with a new blank mesh (and meshfilter), then edit the underlying mesh data using the data from the fbx.

you'll want to populate the following:

mesh.vertices mesh.uv mesh.uv1 mesh.uv2 mesh.normal mesh.tangent mesh.triangles

The fbx will have all of this data (except possibly for uv1 and uv2, which are optional). you just need to create your mesh from scratch using the data, pump it into a gameobject, and display it.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Instantiate rigidbody, transform or gameobject? 1 Answer

XBox Controller Angle of Fire Incorrect 0 Answers

Convert FileStream to Gamobject? 0 Answers

How to Destroy the instances of 2 gameObjects at the same time? 1 Answer

C# GameObjects Instantiate Into Each Other Issue 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges