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 immersiveGamer · Jan 25, 2015 at 10:47 PM · meshbugscriptableobjectreferencemeshfilter

Assigning SharedMesh is creating an unreferenced instance

I've been creating a database for game object parts. I have generic prefabs and I am giving them new materials and meshes based on type. The data base is a custom asset using scriptable objects and is organized as so: Database -> FamilyType (all share same material) -> UniquePiece (each have a unique mesh). Each level is a scriptable object so that later I can import and export parts of it.

The is all works great but the problem is the mesh on the new game objects. When I go to inspect the game object in the scene the MeshFilter shows that the mesh is Instanced and when I click on it sure enough it doesn't link back to the mesh in my assets. It works just fine for the material. I am putting it on SharedMesh on the MeshFilter just like the material for the renderer. I just don't know what is wrong! I've tried multiple things. Putting the material on the piece instead of family level to see if the same happened (didn't). Tried assigning the mesh after, before, not making a new piece reference, etc. Here is the code for making the new game object from the database and an image showing the mesh and material on the created game object.

 public GameObject MakePiece(int family, int piece)
 {
     PieceInfo pieceInfo = families[family].pieces[piece];
     GameObject newPiece = Instantiate(genericPiece[pieceInfo.genericIndex]) as GameObject;
     newPiece.GetComponent<MeshFilter>().sharedMesh = pieceInfo.mesh;
     newPiece.renderer.sharedMaterial = pieceInfo.mat;
     newPiece.GetComponent<Block>().info = pieceInfo;
 
     return newPiece;
 }

alt text

screenshot-2015-01-25-163720.png (13.7 kB)
Comment
Add comment · Show 3
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 immersiveGamer · Feb 06, 2015 at 08:34 AM 0
Share

So no solution to this problem? Perhaps it is a bug ... might move this over to Unity Forums and make a topic about it. Really frustrated that this is not working as it should (or at least I think it should, which is always the case isn't it).

avatar image Baste · Feb 06, 2015 at 09:03 AM 0
Share

Where are you grabbing the mesh in the PieceInfo class from? Remember, if at any point you have a meshfilter that you call .mesh on, you'll be generating a cloned instance of it, as specified in the docs. This is also the case if you're grabbing it from a meshfilter that's a part of a prefab.

avatar image immersiveGamer · Feb 06, 2015 at 09:13 AM 0
Share

@Baste, thanks for the response. I combed forums and found someone else that was having the same problem. Since it is a custom asset I set the mesh in the editor which is why I was confused to why it wasn't working. But it was just as you said. I had to go through each script to finally find it but there it was a reference to .mesh elsewhere ins$$anonymous$$d of .shared$$anonymous$$esh. A stupid mistake really and wouldn't have noticed it ever unless I was swapping meshes checking it. I'll probably delete the question since it is a non problem.

0 Replies

· Add your reply
  • Sort: 

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

20 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

Related Questions

Selected Mesh in inspector is missing name, the link to mesh in assets is also missing 1 Answer

How Can I change the 3rd person controller Mesh? 2 Answers

Procedurally generated Mesh not updating? 1 Answer

Scriptable object keeps referencing the objects? 1 Answer

Scriptable Objects, how to force Include in Compile / Build without referencing it in the scene? 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