• 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 slehmann101 · Feb 12, 2015 at 10:43 AM · meshverticesmapvertexmeshfilter

Creating a mesh for an overview map

I am generating a 2d procedurally generated map, and I would like to create a map to display an overview of said map. As i know it will be slow to have a game object on the overview map for every single tile in the world, I have decided to use a mesh. Having never used meshes before I am running into some trouble.

I have a meshFilter like so:

 private MeshFilter meshFilt;
 meshFilt = GetComponent<MeshFilter>();

and I am then trying to set the vertices of the mesh to the locations of the tiles:

  mesh = meshFilt.mesh;
     Vector3[] keys = revealedTiles.Keys.ToArray<Vector3>();
     mesh.vertices = keys;
     Color[] colors = new Color[mesh.vertices.Length];
     Random r = new Random();
     for (int i = 0; i < keys.Length; i++)
     {
         colors[i] = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f));
 
     }
     mesh.colors = colors;

Where keys is an array of Vector 3's, which are part of a dictionary. So basically what I am doing is setting the vertices of the mesh to an array of vector3's that represent the map coordinates of every tile (1,1 1,2 2,5 .etc).

Currently I am just setting the colors to a random color, just as a proof of concept.

However, the issue is that this does not seem to display anything. In the unity scene view I am getting an outline of a box that appears to be the right size, but it has nothing within it. In the game view nothing appears. I have checked that this code is running, and all of the vertices are being set properly. Any and all help is appreciated, and if anyone has a better idea on how to do this, I am more than willing to listen.

Thank you.

Edit: Here is a view of the scene view: scene view

untitled.png (56.8 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 · Feb 12, 2015 at 11:55 AM 1
Share

You are assigning vertex positons, but you don't built any triangles from them so there is in fact nothing to display: No real mesh exists as there are no polygons in it, justa bunch of vertices with no connections between them. Also note that if you assign colors to the vertices, you have to use a shadeder that supports vertex colors, otherwise the colors won't show.

Check the Unity API for the $$anonymous$$esh class for an example of how to built a mesh by script.

avatar image hexagonius · Feb 12, 2015 at 12:18 PM 0
Share

I agree, look it up here:

http://docs.unity3d.com/ScriptReference/$$anonymous$$esh.html

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Mesh.vertices are all 0? 1 Answer

Why vertex positions appear (0.0, 0.0, 0.0) ? 1 Answer

Is it possible to make vertices defined by a mesh and mesh filters animating? 0 Answers

Changing Y Value in Vertex Array? 1 Answer

Mesh Vertex 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