Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - petrucio

Pages: [1]
1
NGUI 3 Support / Re: how to detect right click on ngui object
« on: October 23, 2014, 03:35:57 PM »
== -2

2
Misc Archive / Re: Developer required for quick UIInput expansion
« on: March 30, 2013, 10:28:49 AM »
It's looking awesome.

3
Misc Archive / Developer required for quick UIInput expansion
« on: February 22, 2013, 02:03:36 AM »
I need an extended UIInput that can move the carat in response to the arrow keys and mouse presses.

Payment:
US$50,00, by PayPal, after delivered and tested

Deadline:
3 business days after we close the deal.

Please respond here or PM.

4
NGUI 3 Support / UIInput navigation
« on: February 11, 2013, 03:10:07 PM »
1. Can I make the cursor navigate an UIInput string using the arrow keys?
2. Can I make the cursor navigate an UIInput with mouse clicks?

5
NGUI 3 Support / Re: UIInput multi-line problem
« on: February 11, 2013, 03:01:04 PM »
You can easilly add multi-line with Enter if you set the 'Submit Key 0' of your UICamera to None.

6
2.2.2 (non-free)

7
Yes, indeed I had doubled checked that my logic was being triggered by an input event before posting that. It runs on either an OnClick or OnDrag, both with the same results and the wrong camera.

8
Done some more testing, and figured out that UICamera.current is not really pointing to the camera that generated the event I'm handling as I expected.

If I expose a UICamera to the inspector, and do a
  1. UICamera usedCam = this.cam ? this.cam : UICamera.current;
, everything works as expected. So it seems that UICamera.current may be bugged?

9
Yeah that seemed obvious enough and was in fact my very first try, but it didn't seem to work at the time. Now that you mentioned it, I went and retested it, and have now found out that it seems to be using another UICamera I have setup in my scene, which has no components involved in the current event whatsoever, to do it's calculations - if I disable it, or change the size and viewport of that camera to be the same as the proper UICamera that should be used, I get the correct values.

So I assumed I was the one doing something wrong and not NGUI, and proceeded to find another way. Turns out I was right all along.

So I guess you have a bug to fix... sorry about that :)

Oh, and the necromancy comment was only because I was reviving a 6 months old dead thread, not because of any code.

10
Actually, UICamera.lastTouchPosition seems to return a value with origin in screen bottom-left. If you want to use that (like me), this is what you want for widget origin in pixels:

  1.         float x = bounds.center.x + Screen.width  / 2;     // (- bounds.size.x / 2) if you want top-left widget origin
  2.         float y = bounds.center.y + Screen.height / 2;     // (+ bounds.size.y / 2) if you want top-left widget origin
  3.  

11
Major Necromancy here, but I'm posting it here in case it helps anyone (maybe myself from the future, googling the same problem again...)

If you want to get the pixel coordinates exactly like the OnGUI coordinates work:

  1.                 Bounds bounds = NGUIMath.CalculateRelativeWidgetBounds(UICamera.current.transform, this.transform);
  2.                 float x = bounds.center.x + Screen.width  / 2 - bounds.size.x / 2;
  3.                 float y = Screen.height - (bounds.center.y + Screen.height / 2 + bounds.size.y / 2);
  4.                 float w = bounds.size.x;
  5.                 float h = bounds.size.y;
  6.  

Or, probably more useful, if you want to get them in relation to NGUI camera coordinates (the origin is at screen center, not top-left):
  1.                 float x = bounds.center.x - bounds.size.x / 2;
  2.                 float y = bounds.center.y + bounds.size.y / 2;
  3.  

Took me a while to get to these, too. Seems most on the NGUI documentation is really sparse, and if it doesn't tell you what you want to know, you are left with trial and error until you find it, or posting here.

12
NGUI 3 Support / Re: Calculating widget's size in pixels at runtime
« on: October 30, 2012, 11:19:44 PM »
Oh dang, virtual pixels! I was so hung on trying to get the ACTUAL displayed pixels, that I failed to realize that that was not what I needed to get it working...

And since I was using center pivots in my widgets, all I need is to calculate the center positions, and that is good for ANY size widgets. So all this was a huge moot point. A good thing about using center pivots as the defaults - as I've read another user ranting about top-left pivots should be the default while searching today...

And yes, I have a UIPanel in my hierarchy - I've read somewhere that I'd need a UIPanel as a DIRECT ancestor of any widget, but by your answer I see that's not the case.

Sorry to take up your time, and thanks for answering. Good luck at Unity. :)


13
NGUI 3 Support / Calculating widget's size in pixels at runtime
« on: October 30, 2012, 03:11:34 PM »
I've searched around a lot, and I aways get to the same answer, that to find the size in pixels of a widget, all I need to do is Vector.Scale the relativeSize of the widget by it's localScale.

My problem is that inspecting relativeSize, I always get (1, 1). If I change the camera's ortho size, I still get (1, 1). If I have a parent to my widget and scale it down, I still get (1, 1). And if I change the resolution, I still get (1, 1).

Using the Calculate* functions of NGUIMath gives me the same wrong results.

I've read somewhere that my widgets need to be direct decendants of a UIPanel? I have a very complicated UI with hundreds of widgets, and I use parent objects to help me organize my widgets and allow me to easily move them around together when needed. Having a direct UIPanel parenting each of my widgets is simply impractical.

Attached a screenshot of the layout of my widget tree and the relevant values. In this case, I'm trying to find out the actual size in pixels of the 'FrameBG' UISlicedSprite, in a resolution of 720p. relativeSize scaled by localScale always returns the local scale of 128, but I know the actual pixel size is (720 / 1080 * 0.8 * 128 = 68.2666).

Pages: [1]