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

Pages: [1]
1
NGUI 3 Documentation / Re: UILabel
« on: March 05, 2014, 11:58:48 PM »
Overflow handling lets you determine what happens when the label's text exceeds the allowed space.
Under what conditions? I've got a bunch of widgets here which seem to partially apply the setting when I select "Resize Height" but then snap back to ShrinkContent.

Edit: Righto, it was having the anchor set to anything other than "None". While this makes sense from a nuts and bolts perspective it's a pretty counter-intuitive workflow, and my experience with the new anchor system thus far is that this isn't the only place where it has that effect. Another example is moving a parent object who's children have anchors on them. In each case I'd expect the anchor to be updated. After all, why would I want something to resize height and expect it to honor a specified height at the same time? Or why would I want to move a parent object and not have its children come for the ride?

2
NGUI 3 Support / My fader script kills my button
« on: June 01, 2012, 09:00:14 PM »
I just recently started using NGUI, so I expect I'm missing something here.

I've got a button in a panel, working exactly as it should.

I then wrote a panel fader script, which I intend to use to turn panels on and off for different parts of my GUI as they are needed. The code is below, minus some event management code.

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class PanelFader : MonoBehaviour {
  5.  
  6.         UIWidget[] fadingWidgets = null;
  7.         float[] originalAlpha = null;
  8.        
  9.         float fade = 0;
  10.         float fadeDir = 0;
  11.        
  12.         public float fadeSpeed = 1.0f;
  13.         public bool beginHidden = true;
  14.        
  15.         float prevRealTime;
  16.        
  17.         void Start()
  18.         {
  19.                 fadingWidgets = GetComponentsInChildren<UIWidget>();   
  20.                 originalAlpha = new float[fadingWidgets.Length];
  21.                 for (int i = 0; i < fadingWidgets.Length; i++)
  22.                 {
  23.                         originalAlpha[i] = fadingWidgets[i].alpha;
  24.                         fadingWidgets[i].alpha = (beginHidden) ? 0 : 1;
  25.                 }
  26.                
  27.                 enabled = false;
  28.                 if (beginHidden) gameObject.SetActiveRecursively(false);
  29.                
  30.                 prevRealTime = Time.realtimeSinceStartup;
  31.         }
  32.        
  33.         void Update()
  34.         {
  35.                 float dt = Time.realtimeSinceStartup - prevRealTime;
  36.                 prevRealTime = Time.realtimeSinceStartup;
  37.                
  38.                 fade += fadeDir * dt * fadeSpeed;
  39.                 fade = Mathf.Clamp01(fade);
  40.                 for (int i = 0; i < fadingWidgets.Length; i++)
  41.                 {
  42.                         fadingWidgets[i].alpha = originalAlpha[i] * fade;
  43.                 }
  44.                 if (fadeDir > 0 && fade >= 1)
  45.                 {
  46.                         enabled = false;
  47.                 }
  48.                 else if (fadeDir < 0 && fade <= 0)
  49.                 {
  50.                         enabled = false;
  51.                         gameObject.SetActiveRecursively(false);
  52.                 }
  53.         }
  54. }
  55.  

The panel fades in and out fine, except that it kills the button when "beginHidden" is true. When I mouse over the button it highlights fine, but when I move the mouse away instead of going back to its normal colour it fades out completely.

I'm guessing that what's happening is that my script is running before NGUI, causing NGUI to grab the completely faded out colour instead of the normal colour. But that's only a guess.

So, the hopefully quick question, is the above approach how I should look at making bits of a GUI appear and disappear?

Pages: [1]