• 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 alyph · Jun 05, 2012 at 05:25 AM · 2dmap

2D Territorial Control Game

I'm trying to make a 2d territorial control game in unity, and wondering what's the best way to implement the 2D world map (which is essentially the main scene of the game.) game looks very similar as the Europa universalis as picture below:

alt text

The map will be split into provinces(regions),and there will be small objects showing up on the map (buildings, cities, armies, characters etc.)

Here are several major points which I'm pondering upon:

  1. how to properly detect mouse click (hovering over) a particular province. I'm thinking to load a relatively low res texture with each province painted in its unique color. and listening to mouse click, transform the click position onto texture coordinates, get the color of that pixel thus have the province Id. but the question is which function can I use to index a texture and figure out the pixel color?

  2. when hovering over a province, it will be highlighted. what's the best way of implementing that. I may need to crop the provincial texture I mentioned above into pieces (one for each province) and dynamically create one object for each. And then hide all of them but the one currently hovering over? Again not sure how to crop texture into small textures at runtime. Or will it be a better choice to use shaders?

  3. What's the most efficient way of displaying small objects on the map? the immediate solution I could think of is to make one plane for each object (the objects need to be spawned/destroyed dynamically)

Thank you all in advance. It's kind of a unusual use of unity, hoping to be able to gather some ideas here.

Comment
Add comment · Show 1
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 alyph · Jun 06, 2012 at 01:28 AM 0
Share

Thanks for the answer, I'll try it out.

1 Reply

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

Answer by Mortoc · Jun 05, 2012 at 05:51 AM

#1 You're on the correct track with your thinking here. You're going to want to enable Read/Write in the import settings for your GUI textures and then use Texture.GetPixel to sample values from the texture.

#2 and #3: You should split all the textures up and draw them independently using either GUI.DrawTexture or as billboarded planes in the scene. Create different textures for the states of your objects (normal, selected, hover, etc). You probably won't need to worry about performance here unless you're going to have 500 or so different images on screen. Keeping draw calls down is good, but for pretty much any modern hardware, I doubt you have much to worry about.

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 alyph · Jun 06, 2012 at 01:29 AM 0
Share

cool exactly what I wanted to know. Thanks a lot!

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

2D Animation does not start 1 Answer

Best way to draw interactive 2d map 2 Answers

What is the best way to make modular (selectable squares) terrain? 2 Answers

Tilemap change size of one of many cell sprites? 0 Answers

Assigning UV Map to model at runtime 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