Author Topic: how to create pie menu in NGUI  (Read 3329 times)

Gameselement

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
how to create pie menu in NGUI
« on: August 18, 2014, 02:44:47 PM »
hello
im creating tower defense game and i want to create a (pie menu or radial menu) for weapon spawner...i instantiate button prefab in panel.Button instantiate perfectly but the problem is i want intantiate button at same point where user tab on screen but button always instantiate at center of the screen...

im using this line of code

var hit : RaycastHit = new RaycastHit();
        for (var i: int = 0; i < Input.touchCount; ++i) {
            if (Input.GetTouch(i).phase.Equals(TouchPhase.Began)) {

            var ray : Ray = Camera.main.ScreenPointToRay(Input.GetTouch(i).position);
            if (Physics.Raycast(ray,hit)) {
            Debug.Log(hit.point);
           var parent : GameObject = GameObject.Find("Panel");
            var child : GameObject = NGUITools.AddChild(parent,myButton);
             child.transform.localPosition = hit.point;
              }
           }
       }

pie menu example screen short

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: how to create pie menu in NGUI
« Reply #1 on: August 18, 2014, 04:48:24 PM »
Not sure why this topic was locked, so I unlocked.

Look into what information you can get from UICamera.GetCurrentTouch (or what it's called in there). That should give you more usable values than doing your own calculations. I mean, since the calculations have already ben done, you might as well use those values.