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
0
Question by Yourdoom · Jun 15, 2012 at 06:20 PM · meshprefabimport

Keep imported meshes reference in prefab

I have a Prefab with a Mesh Filter and various scripts, I also have a .blend file which Unity imports as a model (same problem with an .obj file) that I want to use in the Mesh Filter.

I take the imported mesh and drag it to the Mesh property of the Mesh Filter (or select the mesh via the asset browser). This works fine and the mesh is drawn correctly during play.

Then I end play, and start play again, and the Mesh is missing. How do I prevent this from happening?

Comment
Add comment · Show 2
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 Wolfram · Jun 15, 2012 at 06:28 PM 0
Share

Does any of these "various scripts" touch/modify that mesh?

I will assume you drag the mesh onto the $$anonymous$$eshFilter while you are in Edit mode, not during Play mode?

avatar image Yourdoom · Jun 15, 2012 at 08:06 PM 0
Share

Jup, in Edit mode.

One script reads gameObject.GetComponent<$$anonymous$$eshFilter>().mesh.bounds.center... removing that read seems to fix the problem.

I can probably work around the problem that way, but I'd rather not manually enter every an offset for every pickup. Is there anyway to get the bounds without messing it up?

If you could add that as a comment I'll accept your answer :) (Why it would mess up a setting like this is beyond me though =/)

1 Reply

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

Answer by Wolfram · Jun 15, 2012 at 08:20 PM

In the comments I suggested that scripts messing with the mesh can cause such a problem.

Normaly, just reading a value such as gameObject.GetComponent().mesh.bounds.center shouldn't cause any problems, though. Which component are you requesting in that call to GetComponent()? Is that script an Editor script/has an "ExecuteInEditMode"?

If you are certain you are merely reading that value, not modifying it, you can try whether using gameObject.GetComponent().sharedMesh.bounds.center solves your problem. But note that modifying anything in sharedMesh will modify the actual Asset in your project!

Also, I forgot to ask: did you drag the mesh in to the actual Prefab that sits in your "Project" view, or did you drag it into the instance of that prefab in your scene?

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 Yourdoom · Jun 15, 2012 at 08:31 PM 0
Share

I'm getting the $$anonymous$$eshFilter (had it in the comment but between less than/more than signs so it got stripped out). And I'm editing the prefab as clones are instantiated at runtime currently (had the same problem before doing that though).

And the script only runs at runtime (just after level finished loading).

Just tested it, using shared$$anonymous$$esh works without resetting the mesh, thanks!

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

Adding a new mesh to a prefab from it's blend file 0 Answers

Replacing skinned mesh prefab problem 0 Answers

Instantiate an imported blender mesh 2 Answers

Maya import. 1 Answer

How to import a mesh NOT as a Prefab 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