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 J-Roossien · Feb 15, 2015 at 08:56 PM · uigridmousepositiontile

UI scrollable rect, get position on content based on mousePos.

I'm trying to make a tile based level editor (runtime) with a normal sized background. So if the user selects a background which is 1024*1024 and the tile size is 64 it would create 16 by 16 tiles. The tiles are just virtual tiles but when placing objects it needs to snap on the tiles.

Now my problem is with bigger backgrounds that don't fit in the editor. I'm using a panel (UI) with a scroll rect and a mask to pan the background in the window. Now my problem is how do I know the position on the background based on the mousePos in the window. alt text

As you can see on the image here the background is bigger then the window you can see. Now when I click on the top left corner on the window I need to know that I clicked on tile [2,1] (red dot). And when I click were the blue dot is it would be tile [4,2]. Now the thing I'm struggling with is that when you move the background more to the right it would be a higher tile number.

How exactly do I get the proper tile based on the mouse position and the scrollable background image.

Here is the level editor how far I made it so far you can just select a background like sand to see it. (You can't do much with it yet)

http://web.clashwars.com/Capise/Web.html

Comment
Add comment
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

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.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

An UI element will follow the mouse and snap to a grid, but why is the grid shifted after every game start? 0 Answers

Sorting the children of a Grid Layout in 4.6 UI 3 Answers

How do I get the grid layout component? 0 Answers

I need to get a Vector3 of the mouse position while i'm editing in the scene view. 2 Answers

How do you save a seed? 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