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 destructor465 · Feb 09, 2016 at 07:15 AM · 2darraytilemapdrawdrawing

Tilemap 2D

Before Unity I was using libGDX(java), now I moving to unity. After some look around unity I realized that it not using any directly draw methods like spritebatch.draw() or something like this. This is good for 3D, you don't need write huge draw code for all reflections, effects and so on, but for 2D games is not really good(I think, maybe I'm wrong). I was trying to rebuild(in unity) my tilemap engine from previous project(in libgdx).


My map is just big two dimensional array of integers, every integer have it's own tile, so in render method for every integer(in view) specific tile is renderer. In this way I also getting nice tile transitions like this: alt text


So my question would be: How to draw tiles in unity?

Also my map is big(1024x1024 tiles, each tile is 16x16), so I do not think that creating game object for every tile is good.

test.png (35.0 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 Zoogyburger · Feb 09, 2016 at 07:17 PM 0
Share

You might want to try this program for tilesets:

http://www.mapeditor.org

and import the maps you make using

http://www.seanba.com/tiled2unity

to learn how to use this go to

https://www.youtube.com/watch?v=NNpLsimyu3I&list=PL_4rJ_acBN$$anonymous$$H3SExL3yIOzaqj5IP5CJLC

avatar image destructor465 · Feb 10, 2016 at 01:05 PM 0
Share

Problem is that my map is generated each time you enter the game, so I don't want to use tiled

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by tanoshimi · Feb 09, 2016 at 07:23 AM

You're right - you certainly don't need (or want!) to create a separate gameobject for each tile in a large map. Instead, you should simply add them as quad faces to a single dynamic mesh. You assign appropriate UV coordinates to the corners of each quad to look up the appropriate tile texture from your atlas.

There's plenty of example code if you search for "procedural mesh", and here's the documentation: http://docs.unity3d.com/ScriptReference/Mesh.html

Comment
Add comment · Show 2 · 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 destructor465 · Feb 10, 2016 at 01:13 PM 0
Share

Thanks :) I will try it

avatar image destructor465 · Feb 10, 2016 at 01:40 PM 0
Share

Also I wan't to know why I can't use something like:

 for (int y = 0; y < mapHeight; y++) {
     for(int x = 0; x < mapHeight; x++)  {
         Graphics.DrawTexture(new Rect(x * tileWidth, y * tileHeight, tileWidth, tileHeigt), tileTexture);
     }
 }

In unity?

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Array of Tilemaps misbehaving 1 Answer

2D Draw text at sprite position with script only 1 Answer

[Tilemap] Can you spawn a Prefab (with colliter) together with a tile when placing it? 0 Answers

Merging Objects (many tiles into one) - 2D 2 Answers

Trouble with tilemaps as prefabs for 2D plattformer 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