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 Muhwu · Dec 26, 2013 at 04:32 PM · 2dmeshmeshfilter

Procedurally generated Mesh not updating?

I have a procedurally generated 2D mesh in a 2D scheme.

 void ConstructMesh()
 {
     mMesh.Clear();

     mMesh.vertices = vertices;
     //mMesh.normals = normals;
     mMesh.triangles = triangles;
     mMesh.uv = uvs;

     mMeshFilter.sharedMesh = mMesh;

     mMesh.RecalculateNormals();
     mMesh.RecalculateBounds();
             //mMesh.Optimize ();
 }

This is called after each update. However, it would appear that it only works once. Basically my script adds quads (2 triangles) in repetition with the intent to create a trail. I see the values updating correctly, but only one quad (The first one) gets displayed.

     mMeshFilter = GetComponent<MeshFilter>();
     mMesh = mMeshFilter.sharedMesh;

The mesh is fetched like this.

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 Spinnernicholas · Dec 26, 2013 at 06:26 PM 0
Share

You don't need to:

 m$$anonymous$$eshFilter.shared$$anonymous$$esh = m$$anonymous$$esh;

When you retrieve a mesh from a mesh filter, you get a reference.

Also, it can be dangerous to use Shared$$anonymous$$esh:

From Unity Docs:

It is recommended to use this function only for reading mesh data and not for writing, since you might modify imported assets and all objects that use this mesh will be affected. Also, be aware that is not possible to undo the changes done to this mesh.

But, that risk is up to you.

Lastly, you are not showing how you are generating your vertices/triangles/UVs. That could be the reason you are having a problem. So, please give us more information.

avatar image wangl5 · May 07, 2017 at 03:34 AM 0
Share

I am having the same issue..

I can load in any mesh from an array but only the first one I load actually renders. Any help would be greatly appreciated!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Spinnernicholas · Dec 26, 2013 at 06:30 PM

Use the built in Line Renderer. I think is does basically what you are trying to do. And, you can change it procedurally at runtime.

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 Spinnernicholas · Dec 26, 2013 at 06:32 PM 0
Share

You may also want to check out the Trail Renderer.

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

2d custom mesh triangulator problem 1 Answer

Why is my script constructed mesh rotating the wrong way 0 Answers

Query if MeshFilter is instantiated or shared? 1 Answer

Bounds of dynamic mesh not updating 1 Answer

Any way to access SpriteRenderer mesh UV2? 0 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