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

Pages: [1]
1
Thank you Aren, that helped. My build target is iOS though I'm testing on PC, so I see that the "Scheme" is set to touch until mouse input is received and then it smartly changes to "Mouse". It all looks intentional. I was just unaware it worked like this.

Thank you for your help.

2
My problem: when I load a new scene / level, UICamera.hoveredObject is always NULL until I input some kind of mouse button event (basically, until I click the mouse). Once I click the mouse, then UICamera.hoveredObject properly returns what I expect -- either the mouse hovered UI element, or UICamera.fallThrough.

What might I be doing wrong?

3
I have a single row of buttons in a Scroll View Grid. I recently added UIButton Scale to all of them so they'd scale up on hover and press.

After doing this, I noticed that when scrolling (finger swipe or mouse drag), it moves slower than 1:1 with the pixels on the screen.... In other words, without UIButton Scale, if I click my cursor on a button and drag to scroll the view, the pixel I click stays directly under the cursor. With UIButton Scale, the original pixel under the cursor lags behind, and you have to do extra work to scroll the view as far.

Presumably, the drag distance has scaled inversely to the button's scale up size? Is there a way to fix this or work around it easily without forgoing the UIButton Scale?

4
NGUI 3 Support / Re: Texture Memory & Labels - Best Practices?
« on: October 09, 2014, 11:12:48 AM »
Yes, for dynamic fonts.

Can anyone tell me where I'd look to examine their textures at runtime? That would be great info. All I currently know how to do is see overall texture memory usage for the entire scene, but I am not sure where to find the actual textures themselves from dynamic fonts.

Thanks!

5
NGUI 3 Support / Texture Memory & Labels - Best Practices?
« on: October 03, 2014, 12:55:03 PM »
Hello,

I am looking for any best practices with using Labels and how they affect texture memory, if we need to worry about that.

  • For example, if I have, say, 10 labels in a scene, all with large, but different font sizes, different colors, does that make a significant impact on memory, and if so, how would I find out how much?
  • In other words, do labels generate large font textures? If so -- in which cases do they share them, when do they get created/destroyed, and how can I find out how large they are?
  • Or is it in general insignificant?

Thanks!


6
NGUI 3 Support / Depth/Sorting of ScrollView relative to other NGUI Widgets?
« on: September 29, 2014, 07:03:40 PM »
Hello,

I have modal dialogs that are set to very high depth, and are supposed to sort in front of all other NGUI elements. However, they sort behind any ScrollViews that happen to be open, even though those have lower depth values.

Is this expected, and if so, what is the preferred method to fix something like this?

Thanks!

7
Thank you. That is exactly what I was looking for. Worked like a charm!
(I feel moderately silly for not having found it, given the name. It's a well-named component, sir.)

8
NGUI 3 Support / [Solved] Way to forward events?
« on: June 22, 2014, 03:52:13 PM »
I have a UI with buttons that have icons that overflow. Imagine a button with an icon sticking off the top of it. The icons need their own colliders so they can be grabbed to drag a ScrollView.

I want the icons to behave like an extension of the button (hover changes button color, clicking activates button, etc). But currently, clicking the icon blocks the click from reaching the button.

Is there a way to link or forward button behavior to the actual button?

9
Okay, I've coded up a solution in the form of a component that I can put on any panel that I want to exhibit this auto-close behavior on external taps. If someone has a better way, or if there's some accepted method, let me know.

Here's the code if anyone is curious. The "Timer" and "InputManager" are my own classes, but this should be readable enough to communicate how it works:

  1.  
  2.  
  3. using UnityEngine;
  4.  
  5. /// <summary>
  6. /// Attach this Component to an NGUI object to disable it any time a tap occurs outside of it and its children.
  7. /// </summary>
  8. public class Component_NGUI_CloseWithExternalTap : MonoBehaviour
  9. {
  10.         /// <summary>This makes the UI immune to auto-closing with this behavior within this amount of time after the ui becomes active.
  11.         /// In particular, this helps prevent the same touch that enables the UI to count as an external touch that will then disable it (this was
  12.         /// a problem on tablet with double-taps).</summary>
  13.         private Timer m_delayTimer = new Timer(0.2f); // Seconds
  14.  
  15.         void OnEnable()
  16.         {
  17.                 m_delayTimer.Reset();
  18.         }
  19.  
  20.         void Update()
  21.         {
  22.                 // While the delay timer is active, this component won't be able to auto-disable the UI. (See note above on the timer.)
  23.                 if(m_delayTimer.Going)
  24.                 {
  25.                         m_delayTimer.Update(Time.deltaTime);
  26.                         return;
  27.                 }
  28.  
  29.                 if(InputManager.InputJustPressed(KeyInputID.MainAction) == false)
  30.                 {
  31.                         // No tap this frame
  32.                         return;
  33.                 }
  34.  
  35.                 if(UICamera.hoveredObject == null)
  36.                 {
  37.                         // Tap this frame, and it was not on any UI. Close this ui element!
  38.                         this.gameObject.SetActive(false);
  39.                         return;
  40.                 }
  41.  
  42.                 if(UICamera.hoveredObject.transform.IsChildOf(this.transform) == false)
  43.                 {
  44.                         // Tap this frame, and it was not on this object or any of its children. Close this ui element!
  45.                         this.gameObject.SetActive(false);
  46.                         return;
  47.                 }
  48.         }
  49. }
  50.  

10
NGUI 3 Support / How to show normal game object in UI?
« on: June 19, 2014, 01:22:47 AM »
Hello, here's a problem I'm trying to solve:

Setup:
I'm using Unity2d. I have many game objects, most with normal sprite renderers. Some are animated (just tweening transforms). Some have multiple sub-objects (imagine a character wearing equipment where each piece of equipment is a sub object).

The Problem:
I have UI elements where I'd like to display these game objects with their sub-objects fully intact, and hopefully also with their animations. These UI constructs would be things like info windows, character dialogs, store catalogs, etc.

I haven't yet figured out how to integrate these normal game objects into NGUI. I try adding UI Anchors to them and parenting them in the editor in the UI heirarchy under UIRoot in hopes of placing them in an item grid or drag view or just a normal panel. But when I run the code, these normal game objects' positions and scales change, as if they aren't part of the UI structure.

Is there a standard way to solve this problem?

(I asked a similar question recently, but this is more generalized.)



11
Hello,

Let's say I have a UI Panel that covers part of the screen, and other UI buttons in the HUD outside the panel that trigger other panels. I want to do two things:

  • If the player clicks outside the panel, I want the panel to close.
  • Additionally, if the player's click falls outside the panel on another button, I'd like it to close the current panel and open the new target panel.

I could hack #1 by adding an invisible collider in the empty space around each panel, but that would make #2 difficult. And I'd rather not have to add extra colliders to every panel I have.

What I'm looking for is a way for each UI element to receive an event like, "There was a click and it wasn't on me." That way I could use that to deactivate the panel, and the click can then run its normal course, whether it fell on another UI button or not.

Is there a way to do this?

12
NGUI 3 Support / Use "Easy Font" with NGUI?
« on: June 10, 2014, 01:27:31 PM »
I am using a package called Easy Font, which creates high quality text (specifically, high quality outlines and shadows, smoother and more readable than NGUI's).

However, I don't know how (or if it's even possible) to drop a normal game object, normal unity 3D text mesh, or other object like an Easy Font text mesh into NGUI's UIRoot hierarchy and then still have it draw correctly as if it were, say, an NGUI label. When running, the object is at a different position and with a different scale than in the Editor.

Is it possible to somehow use other objects like this under the UIRoot structure?

Pages: [1]