Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by satishkumarlaksh · Mar 29, 2018 at 08:16 AM · androidtextureassets3d modelsthumbnails

Create thumbnail of 3d model for Mobile platform

Hi All,

My scenario is as follows:

I am working on an app targeted for mobile platforms like Android. I host some 3d models as assets in a webserver. These models are fbx files. I present a grid view of the available assets in webserver to the user, where each grid item represents a 3d model as a thumbnail image.

I can download the assets at runtime using UnityWebRequest and create thumbnails using the following code:

 Texture2D texture = null;
 texture = AssetPreview.GetAssetPreview(myModel);

The problem is that this code works only inside Unity editor. As these APIs are not available for other platforms, the problem of creating thumbnails for 3d models looks hard to address.

On searching the forums, I found the following approach:

  1. Create a texture out of the 3d model

  2. Use the texture to display in the grid item

However, creating a texture out of 3d model looks tricky. I tried something on the lines of:

 Renderer renderer = myModel.GetComponent<Renderer>();
 
 if(renderer != null) {
     Material material = renderer.material;
     Debug.Log("material = " + material);
     Texture texture = material.GetTexture("_MainTex");
 
 }

Renderer is null for the top level component of the 3d model.

As the 3d model is composed of several child components, the material exists only for those child components. Iterating through the child components and creating texture out of them doesn't look right.

I would like to know:

  1. Is there any easy approach to create thumbnail image out of 3d model

  2. Is there any other way to solve this issue

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
1
Best Answer

Answer by Remy_Unity · Mar 29, 2018 at 10:24 AM

The method you mention will get you the texture currently used by the 3D model, not a thumbnail of your model.

To create a thumbnail you will have to render the model to a texture. The easiest way to do this is to add your model to the scene, use a camera to look at it, and render what the camera sees to a render texture : https://docs.unity3d.com/ScriptReference/RenderTexture.html

You can later on use this render texture on a quad or anything you want.

Also, I don't know if your app is meant to dowload a lot of models, but a better approach would be to generate the thumbnails offline and store them on the webserver alongside the fbx.

Doing this you can fetch all the thumbnails first, and only download the full models when you want to display them.

Comment
Add comment · Show 1 · 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 satishkumarlaksh · Mar 29, 2018 at 12:09 PM 0
Share

Thanks for the good suggestion. The idea of RenderTexture would definitely help for cases where the thumbnail has to be generated from a model rendered in a scene.

However, in my case, I thought that I would require the thumbnail to be generated without rendering it to a scene. As you had indicated, the better approach would be to generate the thumbnails externally and host them in webserver which in turn could be downloaded into the app. $$anonymous$$y initial idea was to avoid redundant network requests to fetch the thumbnail and the 3d model separately but after consideration, I agree that it is fine for my usecase. Thanks for your answer which would help someone in the future too.

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

77 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to handle many highly detailed models in a mobile device ? 1 Answer

Texture problem android 0 Answers

Android Plugin: Load assets from APK, but have low-level access to AssetManager. 0 Answers

Joysticks disappears Android 1 Answer

Saving and loading to/from Android 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