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

Pages: [1] 2 3
1
NGUI 3 Support / Re: How do I keep a UISprite from going off-screen?
« on: June 13, 2014, 02:50:45 AM »
Thanks, that's what I'll do.

However I've encountered what looks like a bug: the method I'm using (the code from my previous post) works fine when the game panel is not maximized. But if I start the game with the "Maximize on Play" option then it doesn't work: the icon's position on screen is NOT clamped to the edges of the screen. And so it disappears if the camera doesn't look at the character.

I don't understand why it doesn't work when the game starts in full-screen mode, but it does if the game window is in a multi-panel layout. Do you have any idea what could cause this issue?

2
NGUI 3 Support / Re: How do I keep a UISprite from going off-screen?
« on: June 11, 2014, 08:23:59 AM »
Thank you ArenMook! So I added this in a LateUpdate() to get the desired behavior:

  1.                         // Clamp the position of the alerted icon so it doesn't disappear if it's behind the camera.
  2.                         float clampX = Mathf.Clamp(iconAlerted.transform.localPosition.x, -Screen.width, Screen.width);
  3.                         float clampY = Mathf.Clamp(iconAlerted.transform.localPosition.y, -Screen.height, Screen.height);
  4.                         iconAlerted.transform.localPosition = new Vector3(clampX, clampY, 0f);
  5.  

It works fine for the most part. The only problem is that when I'm running away from the NPC sometimes the icon comes back towards the middle of the screen as if I were facing the NPC (although he's in my back).

So I would need a method to keep the icon from leaving the screen's edges if the NPC is behind the camera. If you have any suggestions about that then please do let me know... :)

3
NGUI 3 Support / How do I keep a UISprite from going off-screen?
« on: June 11, 2014, 03:17:35 AM »
Hello,

I have a UISprite which follows an NPC character (an "alerted" icon) and currently if I turn away from the NPC the UISprite goes off screen (because the character is now behind us).

But I would like to actually keep the UISprite on screen, just hugging and sliding along the sides of the screen rather than disappearing altogether. What would be the best way to achieve this behavior?

Thanks,
Seith

4
NGUI 3 Support / Re: Atlas Maker Popup is a CPU eater?
« on: March 18, 2014, 06:18:07 AM »
That's weird I just noticed the same thing this morning in my project. The way I saw what was happening was by opening Unity's Profiler and checking "Profile Editor". The UIAtlas window was causing a lot of CPU work as it was constantly listening for changes and image file selection. So I closed the UIAtlas window and everything went back to normal.

I have always had the UIAtlas up in my layout and it never caused any problem before. But I had noticed something was wrong since the last NGUI update (or maybe the one before); Unity was slower than usual and "acting busy". It's just a coincidence that I managed to find out where that was coming from and I saw your message one hour later... :)

5
NGUI 3 Support / Re: Forcing a UIPopupList to close?
« on: March 17, 2014, 04:04:13 PM »
That works. Thanks ArenMook!

6
NGUI 3 Support / Re: Forcing a UIPopupList to close?
« on: March 16, 2014, 06:02:43 AM »
Thanks ArenMook. However that doesn't quite work in my case: in my inventory system I have slots which are UIButtons and when I activate one by pressing the gamepad's B button then the UIPopupMenu appears.

If I use the code you gave me the popup menu indeed disappears but the focus on my inventory slot is also lost. I tried doing:

  1. UICamera.selectedObject = mySlot.gameObject;
  2.  

But that didn't work: since the focus of the UICamera is not null the popup menu does not close. So I tried:

  1. UICamera.selectedObject = null;
  2. UICamera.selectedObject = mySlot.gameObject;
  3.  
But that doesn't work either because although the popup menu does close, the camera focus does not go back to slot/button (it remains null).

So my question is: how can I close the popup menu without losing the focus on the button which hosts the popup menu?

7
NGUI 3 Support / Forcing a UIPopupList to close?
« on: March 15, 2014, 05:55:29 AM »
Hello, I'm trying to get a UIPopupList to close via scripting. So far the only thing I found is ".isOpen" but that can only be queried. Is there a way to actually close the popup? Thanks...

Just to be clear: this is to be able to close the popup without actually validating the current selection, in effect canceling the popup action.

8
NGUI 3 Support / Giving focus to a UIButton
« on: February 19, 2014, 12:37:27 PM »
Hello, I have a couple of buttons that I show and hide as my game UI requires but the problem is I don't know how to give focus to a button after I just activated it. The UI is manipulated via a x360 gamepad and I would like to be able to navigate between the buttons by using the left analog stick up/down.

But as I said I need to highlight ("hover") a specific UIButton so that pressing a button on the gamepad will trigger the OnClick method of said UIButton.

9
NGUI 3 Support / Re: Same user input to show and hide a panel?
« on: January 30, 2014, 12:48:55 PM »
The thing is the button (being the only button) is selected by default it seems.

So what I did is disabling the UIButton component by default. Then I added an Update function to track when the interaction button is NOT pressed and if the alpha of the panel is 1 (meaning the panel is visible) then I enable the UIButton component. That way the button does not register a press as soon as the panel is visible.

If the panel itself were properly disabled to begin with, and then enabled would the UIButton also catch the button pressing right away? Maybe I should try that...

10
NGUI 3 Support / Same user input to show and hide a panel?
« on: January 30, 2014, 09:10:49 AM »
Hello, I have a very basic question: Pressing the "B" button on the gamepad activates a panel in which lies a UIButton. But this UIButton's action is to close the panel when it is clicked. So when I press "B" on the gamepad the panel shows up (just the alpha toggling to 1) but as soon as I release the button the panel of course hides itself (alpha back to 0) because the UIButton does its job.

It's a typical case of the snake eating its own tail. What would be the proper way to achieve this simple behavior (same user input to show and hide a panel)? Thanks...

11
NGUI 3 Support / Re: Discrepancy between scenes with new anchoring system
« on: January 06, 2014, 11:43:59 AM »
Alright, the solution for my problem turns out to be that my main camera didn't have a "UICamera" script component attached. Once I did that, NGUI was able to correctly identify the main game camera (ignoring the water reflection camera) and there was much rejoicing...

Thanks again for your help ArenMook!

12
NGUI 3 Support / Re: Discrepancy between scenes with new anchoring system
« on: January 05, 2014, 11:12:31 AM »
For anyone meeting the same behavior: It would seem Unity's own Water 4 prefab is the culprit. There is an automatic camera created for the water reflections and that camera insists on having the "UI" layer (used by NGUI) in its culling mask. This is what causes the problem I'm encountering.

I've communicated the info to ArenMook to see if he can reproduce the issue on his side...

13
NGUI 3 Support / Re: Discrepancy between scenes with new anchoring system
« on: December 31, 2013, 02:16:51 PM »
I've just updated to 3.0.8f3 but the problem is still present.

14
NGUI 3 Support / Re: Discrepancy between scenes with new anchoring system
« on: December 30, 2013, 02:49:11 PM »
The reason why I have several panels is that each of them hold specific widgets linked to completely different topics. So I just use the alpha value of the panels to change the visibility of all the widgets within with one fell swoop. Do you suggest that I should manage the visibility/alpha channel of each element individually?

I followed your advice and put the anchor code in the Start() function, rather than the Update(). I also removed the anchoring of the panel and reset its translate values (0, 0, 0).

Alas that doesn't fix the issue. The label still appears in the wrong place. Again, the weird thing is that in one scene the label appears in the correct position on screen (following its target transform), but in another it appears completely offset. Both scenes are in the same project and use the exact same NGUI prefab. That's what I don't understand...

15
NGUI 3 Support / Re: Discrepancy between scenes with new anchoring system
« on: December 30, 2013, 10:08:36 AM »
Alright, here's exactly what I'm doing: first I'm not instantiating anything, the prefab is in the scene by default. My NGUI hierarchy is as follows:



And here are all the elements. First, the UI Root (2D):



Then the UI Camera:



Then the Panel:



And finally the label itself:



Now here's the code I use in my Update() function to position the label. The objectLabel_target transform is an empty transform that gets placed in the correct position in the world to make the label appear over certain items. There can only be one object name at a time (hence the need for just this label):

  1.                         // Position the label.
  2.                         objectUILabel.leftAnchor.target = objectLabelTarget;
  3.                         objectUILabel.rightAnchor.target = objectLabelTarget;
  4.                         objectUILabel.topAnchor.target = objectLabelTarget;
  5.                         objectUILabel.bottomAnchor.target = objectLabelTarget;
  6.                         objectUILabel.hideIfOffScreen = true;
  7.  

The problem is that the label does not appear at the right place on the screen. It is arbitrarily offset too high and on the left (by about a quarter of a screen), although the target transform is exactly at the correct position in the world.

I hope this will help you pinpoint the problem...

Pages: [1] 2 3