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
2
Question by yigitcan · Dec 29, 2011 at 01:52 PM · performancegriddynamicdesign

Dynamic Grid - A design problem.

Hi,

I want to create a dynamic grid for my project. Simply put, I want a grid on a plane that is dynamically redrawn in every update, according to the size and location of the object (a rectangular shape) that is placed on the plane. For example in the begging there is no grid on the plane, but when i drag my object on it, I want a grid to appear that takes the objects position as reference point (to adjust itself so that make sure the recent object fits in a cell perfectly) and dimensions of the object as its cell size. I want to use it as a guide for the user. When the object is dragged around, the grid is also moved or redrawn. Grid disappears when the object is locked to the plane. Similarly, when a new object is dragged on the plane same procedure applies.

I cant think of a good, performance friendly solution for this. Is creating the grid cells as a game objects a good idea ? I might need to access to the information of any cell as in location or size later on so the whole grid cant be just a texture.

Please share your insights and any suggestion would be appreciated.

Comment
Add comment · Show 6
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 yigitcan · Dec 29, 2011 at 04:33 PM 0
Share

no one has an idea?

avatar image asafsitner · Dec 29, 2011 at 09:19 PM 1
Share

You can have a second plane with a grid texture on it, then scale that plane in proportion to your object's size. You can possibly save whatever data you need about the cell in a struct array for later access and modification.

You can get the size of the object by accessing it's bounds via collider.bounds.size.x and collider.bounds.size.z

avatar image yigitcan · Dec 29, 2011 at 11:38 PM 0
Share

First of all thanks for the answer. The plane size is fixed, so if i scale the texture layer plane, it would be wrong. $$anonymous$$aybe I can keep the texture plane idea and try to draw the grid dynamically somehow (dont know how). The problem begins where I drag my object around on the plane, and the grid should follow the object. I mean practically the object could be put anywhere on the plane, but then the grid should be adjusted. This may sound weird but its a part of the whole idea..

Do you think if I get to work the idea of dynamically drawing the grid in each update, would it be killing the performance ? Or even worse, if I make up the grid out of game objects (one for each cell) and remove and recreate them after every update. (re positioning might be tricky..)

avatar image asafsitner · Dec 30, 2011 at 06:19 AM 0
Share

Creating and destroying an array of game objects every frame will definitely kill your performance.

What I meant to do is keep two planes, one to represent the dynamic grid. You can make it a child of the object you drag on the placement plane so it will follow it around, then upon placement of the object on the placement plane, break the parent relationship of the grid plane and move it out of sight, perhaps even disable it altogether.

If the grid plane has a texture with fixed cell size, let's say 1x1 Unity Unit (1 meter) to make it easier to manipulate, then resizing the plane will result in the grid increasing or decreasing in size accordingly. Alternatively, you can just adjust the tiling of the texture to achieve the same result with far less potential bugs (scaling can cause a lot of funky stuff)

avatar image yigitcan · Dec 30, 2011 at 11:09 AM 0
Share

O$$anonymous$$, finally I came up with a design like following, inspired from what you said as well

1) Create a 'big' unit grid.

2) Resize it wrt to the size of the object.

3) relocate the grid so that its center cell will match up with the object.

4) $$anonymous$$ask the parts of the grid that are out of the place (from orthogonal cameras perspective)

5) for each update just relocate the grid and adjust the visibility of the cells according to the step 4.

Havent tried it yet but I see it could work. Just for the record, I did try the creting and destroying at each update solution adn traced the FPS rate, it dropped drastically after 10 seconds or so. Wasnt a good idea, tho thats why I asked the quiestion :)

Show more comments

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

can anyone tell me about making grid manualy 2 Answers

Fastest way to draw a grid of textures 2 Answers

What is the best way to create 3D tile based levels in Unity ? 1 Answer

Performance While Loading Map 2 Answers

Terrain Performance on Shaded Terrain 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