Author Topic: How to divide the GameView into equal parts  (Read 4757 times)

csdn_ss

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
How to divide the GameView into equal parts
« on: June 14, 2014, 10:37:03 AM »
How to divide the Game View into equal parts
Just like the App named "Don't step on the tip"
I want in Camera , I can see 16 Buttons(Four rows and four columns)divide the view in equal parts
But I don't know how to set position
there are too large space
I use Screen.width/4 and Screen.higtht/4 ,but in UIRoot Camera, transform can't be set value like this
The next picture is what I want in Play Game View ,it's takes all the screen

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to divide the GameView into equal parts
« Reply #1 on: June 15, 2014, 05:20:43 AM »
You shouldn't be trying to set transform.position, but transform.localPosition should be fine if you're using a pixel-perfect UIRoot.

The best way to achieve what you're trying to do is to use anchors. The anchor system has both absolute pixel offsets as well as relative, percent-based values. I suggest examining its documentation and playing around with it.

csdn_ss

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: How to divide the GameView into equal parts
« Reply #2 on: June 15, 2014, 10:38:45 AM »
Could you please tell me how to use anchors system by using percent-based values detail
Is it right where  I find anchor system in my picture below.
Better give me a picture ,Thank you very much


csdn_ss

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: How to divide the GameView into equal parts
« Reply #3 on: June 15, 2014, 10:55:48 AM »
How to set UIRoot pixel-perfect

csdn_ss

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: How to divide the GameView into equal parts
« Reply #4 on: June 16, 2014, 05:17:35 AM »
The last question is each button(16 buttons) on the second picture,seem one by one , close to each other.
but they are not,I just Ctrl + D,and put them like this , I want each button take 25%width,25%height(view in Camera ) ,and close to each other.They can expand or change their size when the camera view expand(Auto fit) .

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to divide the GameView into equal parts
« Reply #5 on: June 16, 2014, 08:41:58 AM »
Check the documentation for UIRect. It explains how to use percent-based anchoring.

http://www.tasharen.com/forum/index.php?topic=7013.0