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 Ben-BearFish · Aug 17, 2015 at 10:01 PM · mesh3dplanecenter

Creating a 3D Plane Mesh Without a Filled Center

I was wondering if anyone knew how to create a 3D mesh plane in Unity that doesn't not have a filled center, much like the UI Image component that doesn't have a center, but edges only?

Here is the 2D Unity GUI equivalent of what I'm trying to do with a 3D plane:

2D Plane with Filled Center

2D Plane with No Filled Center

filledcenter.png (39.0 kB)
nofilledcenter.png (39.3 kB)
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 Cherno · Aug 18, 2015 at 06:04 AM 0
Share

Please post your mesh generation script.

avatar image puppeteer · Aug 18, 2015 at 11:07 AM 0
Share

I think you mean a Wireframe?

1 Reply

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

Answer by cjdev · Aug 18, 2015 at 09:07 AM

Without really knowing what it is you're trying to do it's a bit difficult to give you a definitive answer, but the basics of procedural mesh generation should get you started. Here is an example that creates a plane of 3x3 squares with the middle square missing:

 List<Vector3> verts = new List<Vector3>();
 List<int> tris = new List<int>();
 
 for (int i = 0; i < 4; i++) //Creates a grid of squares 3 X 3 with a hole
 {
     for (int j = 0; j < 4; j++)
     {
         verts.Add(new Vector3(i, 0.5f, j)); //Adds each new vertex in the plane
         //Skip if four vertices cant be connected with tris
         if (i == 0 || j == 0 || (i == 2 && j == 2)) continue;
         //Adds the index of the three vertices in order to make up each of the two tris
         tris.Add(4 * i + j); //Top right
         tris.Add(4 * i + j - 1); //Bottom right
         tris.Add(4 * (i - 1) + j - 1); //Bottom left - First triangle
         tris.Add(4 * (i - 1) + j - 1); //Bottom left 
         tris.Add(4 * (i - 1) + j); //Top left
         tris.Add(4 * i + j); //Top right - Second triangle
     }
 }
 
 Vector2[] uvs = new Vector2[verts.Count];
 for (var i = 0; i < uvs.Length; i++) //Give UV coords X,Z world coords
     uvs[i] = new Vector2(verts[i].x, verts[i].z);
     
 GameObject plane = new GameObject("ProcPlane"); //Create GO and add necessary components
 plane.AddComponent<MeshFilter>();
 plane.AddComponent<MeshRenderer>();
 Mesh procMesh = new Mesh();
 procMesh.vertices = verts.ToArray(); //Assign verts, uvs, and tris to the mesh
 procMesh.uv = uvs;
 procMesh.triangles = tris.ToArray();
 procMesh.RecalculateNormals(); //Determines which way the triangles are facing
 plane.GetComponent<MeshFilter>().mesh = procMesh; //Assign Mesh object to MeshFilter
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 Ben-BearFish · Aug 18, 2015 at 04:13 PM 0
Share

You pretty much gave me the base for what I need. I was trying to do a 9-sliced mesh plane. I didn't realize it's just 9 different planes re-sized. Here's a similar answer, but with more control to the edge planes.

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

28 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

Related Questions

How do i access the MeshExtrusion.cs from Unity's PE? 1 Answer

Ways to render a real world 3D environment given a GPS coordinate 4 Answers

Is it possible to generate a 2D view of a 3D object at runtime? 0 Answers

2D vs 3D mesh deformation. 0 Answers

Plane pivot point creating 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