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

Pages: [1] 2
1
Misc Archive / Sprite Selector not working in Unity 2017.1.3
« on: March 01, 2018, 12:49:46 AM »
I just noticed the sprite selector wasn't working in my project when clicking on "Sprite" in the UISpriteInspector (in 2017.1.3).  I looked back through source control and while I have made quite a few changes to Ngui 3.11.4 core, none had anything to do with this and this was working just a few weeks ago when I refactored the look of my chat window.  Then I changed to a fresh project with just Ngui installed and the same behaviour was exhibited there.

The window is clearly displaying - OnGui is being run ok for the sprite selector - but no window displays.  The Unity title bar does deactivate though - clearly it thinks the window is there, but it is just not being drawn.

Anyone know what the fix here is?  If it is upgrade to a newer version of unity or wait for unity to fix it, that would be fine.   But I am welcome to any known fixes too.


2
I wrote code to this a while back using ngui sprites.  Its not a line renderer, but it works and it operates under the confines of the ngui sprite drawing system (so depth, etc work) with the limitations of course of it being a line drawn as a sprite.

I don't use this code much but I never see any problems with it so I assume it still works ok.  Basically you create a sprite (for me just a solid white color sprite) with UILine attached, and then you can draw a line between two points.  I believe SetWidthAndHeight is an extension method I use so you will need to replace that with the width and height fields of the sprite.

In the code I use, I have a static method that draws lines and uses a predefined line template so I basically just give it a parent, start and end position and it draws the line to make things easy.

  1.     [RequireComponent (typeof (UISprite))]
  2.     public class UILine : MonoBehaviour
  3.     {
  4.         private UISprite    Sprite;
  5.         public Color        Color { get { return Sprite.color; } set { Sprite.color = value; } }
  6.         public int          Depth { get { return Sprite.depth; } set { Sprite.depth = value; } }
  7.  
  8.         private void Awake ()
  9.         {          
  10.             Sprite = GetComponent <UISprite> ();  
  11.         }
  12.  
  13.         public void Draw (Vector2 startPoint, Vector2 endPoint, int lineWidth)
  14.         {
  15.             if (endPoint.x < startPoint.x)
  16.             {
  17.                 var pointSwap         = startPoint;
  18.                 startPoint            = endPoint;
  19.                 endPoint              = pointSwap;
  20.             }
  21.  
  22.             var distance    = Vector2.Distance (startPoint, endPoint);
  23.             var difference  = startPoint - endPoint;
  24.             var angle       = Vector2.Angle (Vector2.up, difference);
  25.             var center      = new Vector3 (startPoint.x - difference.x / 2f, startPoint.y - difference.y / 2f);
  26.  
  27.             transform.localPosition = center;
  28.             transform.localRotation = Quaternion.Euler (0, 0, angle);
  29.             Sprite.SetWidthAndHeight (lineWidth, distance);
  30.         }
  31.     }
  32.  

3
NGUI 3 Support / Application focus and hover events
« on: November 07, 2016, 09:44:17 PM »
When I unfocus my app I still get hover events (I can hear them) - e.g. if I have chrome up on top of Unity I can hear buttons being hovered while I am browsing.  My app is set to run in the background.  I trivially fixed it by keying off whether the application was focused in UICamera before applying a hover object.  Was there a reason this is not done in NGui already?  Something I am not thinking about?

Thanks!

4
NGUI 3 Support / Re: 3d text burry
« on: July 23, 2016, 08:31:50 PM »
I have a number of widgets on my nameplates - three labels, three progress bars, labels for floating text, icons, etc.  This is part of the reason why I thought a panel per nameplate might be better.  I was under the impression that changing a widget would invalidate the panel, so if I had 30 nameplates under one panel, a single (health) progress bar changing would require the panel (and all 30 namepletes) to re-process.  I figured that at some point the drawcall cost would be outweighed by NGUI CPU cost for the invalidation.

In any event, good to know.  Thanks!

5
NGUI 3 Support / Re: 3d text burry
« on: July 17, 2016, 02:11:24 PM »
So mucking around today I have been able to get the 2d nameplates in a place where I am happy with them.

So in addition to the first question (which I am still curious about), the second question now is: how expensive is changing panel depths?  I.e. for 2d nameplates, I am dynamically changing nameplate panel depths based on the distance from the camera (where each nameplate has its own panel).  While I would like to avoid having panels on each one, I figure that has to be faster than having a single panel and changing a ton of widget depths (and a lot easier).

6
NGUI 3 Support / 3d text burry
« on: July 17, 2016, 09:09:55 AM »
For a while now I have used 3d nameplates, and they work fine, and aesthetically look the way I want, but the text just looks bad.  I also support them as 2d nameplates - clearly they looked super crisp, but a lack of depth information and some other things make me dislike them a bit.

Is there any way to get the text crisper or is this just a limitation of rendering the text in 3d space?

7
Super awesome.  Updating to the newest version fixed this issue!  I am assuming the color change or the linear space work was the fix.  Whatever the reason, I am really happy this is finally resolved.  And it required no code changes on my side.  My favorite kind of bug fix!

8
I am having trouble getting the same color to match when tinted directly via the label color vs encoded as a color in a label.  I've had this problem for a few years now with one of my controls, and I have kind of ignored it.  Now I want to fix it.  I am aware of the color tint override/color encoding available when encoding colors in label text, and I have read all the forum posts on similar topics.

As a simple test case, I drop two labels in the scene, using NGui fonts, with no effect/gradients specified (basically a pure, basic label).  I color one using the tint, and the other with a white tint but encoded with the same color as the first label (using the color tint override shouldn't matter i assume in this case, but I tried both anway).

The colors do not match.  The color on the encoded text label is brighter.  Now, I could probably find an encoded color that matches the tint version and simply map them depending on the method of color I am using, or I could consolidate my logic to always use encoded colors, but honestly that is a bit of a nightmare.

I have tested this in a new project with just ngui imported, and using one of the ngui fonts, I can get the color to match sometimes.  Sometimes, they will not match, and then i will switch fonts around, or something, and then they will match (for the same font combination)!  It is almost like the font colors are not being updated immediately in some cases until something triggers it.

This is driving me a bit nuts :-).  I am using linear lighting / NGui 3.9.4.  I am about to upgrade to the newest just to make sure that doesn't fix anything.

9
NGUI 3 Support / Re: Deselect input on disable?
« on: September 15, 2015, 09:20:28 AM »
3.9.2.

The use case is pretty simple.  Make an input and select it.  Disable its parent while it is selected.  I would expect it to be automatically unselected when this happens, but it is not, since to me having something selected implies it is selectable in the first place.

Add an OnDisable and set IsSelected to false on the input.  Note that even after disabling, and then re-enabling the container gameobject, the input is still selected.

This particular case is in a tabbed dialog with a bunch of tabs with nested scroll views.  On several of the content pages are inputs (used for searching the contents of that tab), and I would like to deselect the inputs if you close the dialog (with escape) while you have them selected (or you die and I force the window closed).

10
NGUI 3 Support / Deselect input on disable?
« on: September 06, 2015, 09:28:36 PM »
On disable I am trying to disable an active UIInput with an override of Cleanup (called from OnDisable) on UIInput.  This, however, doesn't work (calling isSelected = false).

Is there a way to do this?  UIInput.selection remains set to the input even after it is disabled and when I re-enable the window the input is still happily focused.

11
NGUI 3 Support / Label color tint vs encoded color
« on: May 14, 2015, 11:26:14 PM »
I've noticed that the color tint for a label is accurate.  For example, grey, (128,128,128).  However, if I encode a label with [808080] the color is a noticeable lighter grey.  This is using TTF fonts.

I have a chat window, and when I add the chat in the chat text list, i encode it to the color of the channel it was sent on.  In addition, I color the input to the channel you are typing in.  They do not match, because the color of the encoded text in the text list is lighter (I tested this on a label at the root with a fully white color tint, with nothing obscuring it, just to make sure).

Why is this the case?

Thanks!

12
NGUI 3 Support / Re: TTF fonts dissapear/garble when alt-tabbing
« on: April 21, 2015, 09:35:28 AM »
Thanks.  This does seem like it is fixable in ngui.

I fixed this in the editor with the code below.  I don't seem to see this problem with standalone builds.  Since I didn't feel like modifying more ngui stuff I just made it affect the editor.

#if UNITY_EDITOR
   /// <summary>
   /// Mark the UI as changed when returning from paused state.
   /// </summary>

   void OnApplicationFocus (bool focused)
    {
        if (focused)
            Invalidate (false);
    }

#endif

13
NGUI 3 Support / TTF fonts dissapear/garble when alt-tabbing
« on: April 20, 2015, 10:21:26 PM »
3.8.2
U5.01f1

Any TTF fonts dissapear/garble when alt-tabbing.

This has happened ever since I moved to Unity 5.  Now, I have seen the disclaimer in Ngui basically saying "go bug Unity, it's not my problem" (always makes me lol a little) but does anyone have any idea if there is a workaround?  Since all of my UI is basically created up front and disabled for the most part, it means the minute you alt-tab you are basically done.

The TTF fonts look so much better than the bitmap ones.  I still use some bitmap fonts.  They appear to have no issues.

14
I tracked down the issue to the tooltip delay.  It would set the ClickNotification to None when the tooltip delay was 0.0001 (I was using essentially no delay).  Once I realized what the code was doing, changing the tooltip delay to 0.5 fixed the issue.

Can someone explain why the tooltip delay is now tied to anything around click processing?  Its not a huge deal, but I would still like to know why this is.


15
NGUI 3 Support / Re: Linear lighting / multiple materials
« on: January 12, 2015, 05:04:14 PM »
So I just realized that the other premultiplied colored shaders were probably for clipping or something, and I made the change there, and everything is working now.

Still not sure if this is the right solution though.

Pages: [1] 2