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
0
Question by chrischu · Apr 21, 2014 at 07:30 PM · 2dgridtilegl

Unity 2D tiles and grid

I am currently working on my first Unity project, which is a 2D strategic RPG (similar to Fire Emblem).

The tile system I developed works pretty well but now I am stuck on overlaying it with a grid.

I modified the code found in this thread and it works pretty well, however now the problem is, that the lines drawn with GL.Vertex3 are drawn above everything but the GUI.

This is a problem since I wanted to have 3 sorting layers (from background to foreground): terrain, grid, units. Units can be bigger than a tile, which leads to a problem when the grid overlaps the unit :(.

Is there a way to draw the lines with GL in a specific sorting layer? Is there another good way to draw a grid?

Thanks in advance!

Comment
Add comment · Show 3
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 robertbu · Apr 21, 2014 at 07:53 PM 1
Share

To get what you want you may have to go with a third-party line drawing solution like Vectrosity. Or alternately you could draw your own 'lines' but creating a mesh of line quads (essentially what Vectrosity does for some line types).

avatar image chrischu · Apr 22, 2014 at 07:40 PM 0
Share

I tried creating my own mesh and rendering that with $$anonymous$$eshRenderer, however the problem is that if I want to have very narrow lines they sometimes become wider (I guess because they are not exactly pixel-aligned or something). So this does not seem like a good option :(.

avatar image gfoot · Apr 22, 2014 at 08:26 PM 0
Share

I don't have time to flesh it out right now, but I converted it and made it editable.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer Wiki

Answer by gfoot · Apr 22, 2014 at 07:50 PM

Did you use MeshTopology.Lines? If so, the lines should always be one pixel wide. If not, try that - it's a parameter to Mesh.SetIndices.

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

21 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

Related Questions

How to use the same tilemaps among multiple scenes (e.g. making it a prefab)? 0 Answers

Drag Rigidbody into slots? 2 Answers

Grid Movement VS Free Movement 1 Answer

What to do with "unloaded" gameObjects? 1 Answer

2D Tile Map Question 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