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 alexander11 · Sep 22, 2016 at 10:15 PM · c#unity 5mesh3dmeshfilter

How do i modify a mesh Filter(C#)?

Hello i would like to know how can i modify a mesh filter in unity (i have gone to the meshFilter API but doesnt say on how to modify the current mesh)???

Comment
Add comment · Show 6
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 Namey5 · Sep 22, 2016 at 11:20 PM 0
Share

$$anonymous$$odify in what sense? Are you trying to deform the mesh?

avatar image rich2020 · Sep 22, 2016 at 11:40 PM 0
Share

I posted an answer over an hour ago, but unfortunately Unity is very slow at moderation.

avatar image alexander11 · Sep 22, 2016 at 11:46 PM 0
Share

well i have been working with CSG and i am having some trouble with this, when i perform a boolean operation the mesh expands(when the scale is not one) or the mesh i have created and try to replace/modify just renders away from the objects position(when the position is not 0). If you know what i mean?

avatar image rich2020 alexander11 · Sep 23, 2016 at 12:08 AM 0
Share

Cam you post some code? Are you trying go modify the msh vertices at run time?

avatar image alexander11 rich2020 · Sep 23, 2016 at 12:11 AM 0
Share

If you follow my link and the thread you'll find out what i am doing. :P

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by felipin · Sep 23, 2016 at 11:41 AM

Hello buddy, alright, the first thing that you must know probably it's how to access the mesh, them you'll need to know how a mesh is structured (vertices, triangles, color, normal, UV, etc.) for you starting to modify meshes.

Here is a little MonoBehaviour showing how that works.

 public class MeshModifier : MonoBehaviour
 {
     private MeshFilter meshFilter;
     
     private void Awake ()
     {
         meshFilter = gameObject.GetComponent<MeshFilter> ();
         
         ModifyMesh (meshFilter.mesh);
     }
     
     private void ModifyMesh (Mesh mesh)
     {
         if (!mesh)
         {
             return;
         }
         
         Vector3[] vertices = mesh.vertices;
         
         // Modify vertices (Move all the vertices one unit to the right)
         for (int i = 0; i < mesh.vertexCount; i++)
         {
             vertices[i].x++;
         }
         
         mesh.vertices = vertices;
     }
 }

Sorry for my bad English.

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 alexander11 · Sep 23, 2016 at 05:06 PM 0
Share

Thanks-ish, but its not fixing my problem visit here look at post #12.

avatar image
0

Answer by rich2020 · Sep 23, 2016 at 11:44 AM

 using UnityEngine;
 using System.Collections;
 
 public class ExampleClass : MonoBehaviour {
     void Update() {
         Mesh mesh = GetComponent<MeshFilter>().mesh;
         Vector3[] vertices = mesh.vertices;
         Vector3[] normals = mesh.normals;
         int i = 0;
         while (i < vertices.Length) {
             vertices[i] += normals[i] * Mathf.Sin(Time.time);
             i++;
         }
         mesh.vertices = vertices;
     }
 }

From here: https://docs.unity3d.com/ScriptReference/Mesh.html

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

245 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 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 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 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 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 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 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

How do i replace a Mesh Filter?? 1 Answer

How do i create a Mesh in the middle of a Catmull spline? 0 Answers

Getting errors with extrusion script. 0 Answers

How do i code a Mesh collider ? 1 Answer

Is there a similar Command to lineRenderer.SetVertexCount for mesh?? 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