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 highpockets · Nov 18, 2015 at 06:10 PM · meshproceduralmeshfilterclear

How do you completely clear a mesh?

Hello,

The heading says it all. I have procedurally made a mesh and it works great, but when I go to clear it with "Mesh.Clear()", the mesh is still there. I have also passed false to the Clear function ( "mesh.Clear(false) ) and it doesn't work either. I want to clear it because this mesh is always changing, and the updates to the mesh are happening correctly, but the old part of the mesh is never cleared, resulting in a large messy mesh.

How can I just delete the mesh and start fresh from code?

Thanks

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 Dave29483 · Nov 18, 2015 at 06:27 PM 0
Share

Did you try following up with;

RecalculateBounds(); Optimize();

I think this forces an update. As far as I am aware, Clear() removes the copy in memory but the changes are not immediately uploaded to the GPU. I'm not entirely sure you can submit a cleared mesh to the GPU.

Better to assign your mesh property to null if you want to visually indicate a lack of mesh data.

Once you have regenerated new data, assign it back to the the mesh property on your $$anonymous$$eshFilter.

avatar image saschandroid · Nov 19, 2015 at 07:12 AM 0
Share

Did you try Destroy(mesh); or mesh.Upload$$anonymous$$eshData(true); (see).

1 Reply

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

Answer by highpockets · Nov 19, 2015 at 02:12 PM

Thanks for the suggestions. I was going about this the wrong way. I just needed to rewrite the vertex positions. My code was adding vertex positions to a list which then was passed to the vertex positions for the mesh, but I never cleared the list when I wanted to refresh, thus it was never clearing the old positions.

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 highpockets · Nov 19, 2015 at 02:58 PM 0
Share

Just a note to anyone who wants to do this in the future. When you want the mesh to disappear without destroying the game object. Just use mesh.clear(false); ( this clears the data, but doesn't visually clear the mesh ), if you are using a list like myself to pass the vertex positions to the mesh then you also need to clear the list listName.Clear();and then you just need to pass the empty list to the mesh vertex array mesh.vertices = listName.ToArray();.

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

36 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

Related Questions

"Baking" to 2d UV Map? 1 Answer

Displaying precision edges of a mesh at runtime? 0 Answers

Artifacts / Stretch Marks in Mesh Manipulation 0 Answers

save meshfilter for retrieval even after app termination iphone android 1 Answer

Mirror vertices procedurally 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