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
1
Question by MaxPower42 · Aug 22, 2015 at 09:34 AM · assetmodelruntimeaccessmorph

Can I read model-data from assets at runtime via script?

So I want to do some morphing between meshes and skeletons. Do I have to instatiate the assets to get to the data? And is there any way to refer to an asset by its specific type (model) or can you only use GameObject for that?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by cjdev · Aug 22, 2015 at 08:26 PM

As far as I know the only morphing Unity supports is Blend Shapes (other than custom mesh creation and manipulation). Is that what you mean? The only real information you can get from the object would be the number of blend shapes. If that's all you want you could load the GameObject from the Resources folder and get the SkinnedMeshRenderer component to access blendShapeCount.

Comment
Add comment · Show 2 · 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 MaxPower42 · Aug 23, 2015 at 07:20 AM 0
Share

Yes, I'm building custom meshes and skeletons from several models with the same "layout" (vertices & skeletons) by interpolating between them. Later I will just extract the actual morph-data from them, so I can skip vertices that don't change at all and speed up the morphing process a little. There may be better ways to morph, but this is the best I could come up with for now and it's an easy way to get some at-runtime-flexibility for those online character generators. I'm also thinking about writing code that will translate a morph target for use with a different mesh, using vertex proximity, normals, raycasting and stuff, but that sure won't be easy. It would be nice, however, because otherwise you would have to generate a million different clothing combinations (every piece for every morph).

$$anonymous$$y question was, if I have to instantiate the resource to get the bone-|ex-data. I guess by calling "load", that's what I'm doing, right? $$anonymous$$y other question was, if I can refer to a resource by type model (or texture, audio clip etc.) and not just by GameObject.

avatar image cjdev · Aug 23, 2015 at 07:53 AM 0
Share

You don't necessarily have to instantiate a GameObject into your scene in order to manipulate or access it's data. Loading the object and assigning it to a variable in your script will let you do what you like with it and then you can instantiate it at a later time if you want to (or not). As for loading resources by type, you can cast the resource to it's appropriate type when you load it like this: Resources.Load("$$anonymous$$yTexture") as Texture. Note that you can't load a GameObject's components though, so you couldn't load a $$anonymous$$eshRenderer from a model for example.

avatar image
1

Answer by Thaina · Aug 24, 2015 at 11:59 AM

Sure you can

You would have find mesh object in your model. That contain vertex and index buffer. You can even create your fresh new model in runtime

http://docs.unity3d.com/ScriptReference/Mesh.html

If you don't want to instantiate you could use Resources.Load you would get asset object. But for loading things in runtime you need to put file you want to be loaded in folder named Resources

Most of asset type in unity 5 let you read, manipulate and generate anything at runtime if you could understand the engine. Not an easy task but not so difficult. Have fun

Comment
Add comment · 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

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

27 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

Related Questions

can you make a prefab but without a model? 3 Answers

Site to download models 6 Answers

Model imported at runtime not showing in-game 0 Answers

Free 3d ready model 10 Answers

Create prefab from gameobjects at runtime 2 Answers


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