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 - jmorhart

Pages: [1]
1
NGUI 3 Support / Re: Scale UIWidget based on DPI
« on: March 05, 2015, 02:01:22 PM »
Figured it out, just had to wrap my head around the math :p Some pseudo code:

physicalPixels = sizeInInches * DPI
physicalPercent = physicalPixels / screenHeight;
spriteHeight = physicalPercent / uiRootActiveHeight;

Hope this can help someone else!

2
NGUI 3 Support / Re: Scale UIWidget based on DPI
« on: March 05, 2015, 01:18:27 PM »
Yep, that part I understand. Physical Size * DPI = size in pixels. So a 1" physical size @ 96 DPI = 96 pixels. The problem is that I have my UI's scaling style set to constrained by height, so that means it's using 96 virtual pixels. How do I convert those virtual pixels to physical pixels?

3
NGUI 3 Support / Re: Scale UIWidget based on DPI
« on: March 02, 2015, 04:41:03 PM »
I figured I'd have to write some code, and I'm fine with that. I think I explained myself poorly as well. What I'd really like to do is scale a UIWidget based on a physical size. For example, make a UIWidget take up 1 inch on the screen no matter what the UIRoot's scaling mode is set to.

4
NGUI 3 Support / Scale UIWidget based on DPI
« on: February 27, 2015, 07:49:18 PM »
Hi all,

I would like to know if there is a way of scaling UIWidgets based on the screen DPI? I understand that the entire UI can be scaled that way by setting the UIRoot's scaling style to Flexible and checking Adjust By DPI. However, I want the majority of my UI to be Constrained, and have just a few UIWidgets scale based on DPI. Any ideas how I would go about doing this? Thanks!

5
NGUI 3 Support / Re: Transform.OverlayPosition sets non-zero z value
« on: February 03, 2015, 04:35:37 PM »
I've figured out a different way to do what I'd like. I used NGUIMath.WorldToLocalPoint and then manually set the z value of Vector3 returned from that to 0. Then set the widget's transform.localPosition to that modified Vector3.

  1. void Update()
  2. {
  3.     Vector3 overlay = NGUIMath.WorldToLocalPoint(transform.position, Camera.main, UICamera.mainCamera, labelTransform);
  4.     overlay.z = 0.0f;
  5.     labelTransform.localPosition = overlay;
  6. }
  7.  

6
NGUI 3 Support / Transform.OverlayPosition sets non-zero z value
« on: February 03, 2015, 03:26:56 PM »
I would like to overlay a label on top of a 3D game object. I have attached a script to the object that does the following in the update loop.

  1. public Transform labelTransform;
  2.  
  3. void Update()
  4. {
  5.     labelTransform.OverlayPosition(transform.position, Camera.main, UICamera.mainCamera);
  6. }
  7.  

I can see in the editor that this is setting the label transform's X and Y positions correctly, but the Z position varies from -10,000 to 10,000 so the label doesn't get rendered. How can I make the Z position always be 0?

Thanks!

Pages: [1]