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.


Topics - Aurigan

Pages: [1]
1
NGUI 3 Support / UILabel Resize Freely truncates content
« on: August 17, 2017, 11:06:54 AM »
A UILabel with 'resize freely' overflow option AND a 'max width' set will truncate content after that max width is hit.

What would be the easiest way to change UILabel 'resize freely' overflow behavior to shrink content once that max width was hit?

2
NGUI 3 Support / Unity 2017.2b2 warnings
« on: July 10, 2017, 03:16:49 PM »
  1. Unable to find style 'AS TextArea' in skin 'DarkSkin' Layout
  2. UnityEngine.GUIStyle:op_Implicit(String)
  3. NGUIEditorTools:BeginContents(Boolean) (at Assets/3rd Party/NGUI/Scripts/Editor/NGUIEditorTools.cs:1362)
  4. NGUIEditorTools:BeginContents() (at Assets/3rd Party/NGUI/Scripts/Editor/NGUIEditorTools.cs:1348)
  5. UIPanelInspector:ShouldDrawProperties() (at Assets/3rd Party/NGUI/Scripts/Editor/UIPanelInspector.cs:589)
  6. UIRectEditor:OnInspectorGUI() (at Assets/3rd Party/NGUI/Scripts/Editor/UIRectEditor.cs:135)
  7. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

3
Hi, still trying to work out details on this so mentioning it here in the off-chance it's already known and/or fixed in a later NGUI version (I'm using 3.11.0).

In 5.6.1p2 Unity added this 'fix':

(900191) - Android: Dropped obscured touch events to prevent tapjacking.

The effect of this is that players who run screen dimming apps like this: https://play.google.com/store/apps/details?id=com.sebmorand.brightcom won't be able to touch anything in the app - the screen dimmer app overlay captures the touch and the NGUI/Unity app underneath doesn't eversee the event.

The was reported on a Galaxy J7 running 6.0.1. On my device (Pixel running 7.1.2) the screen dimmer app appears to be non functional so doesn't break anything, also means I have no way of reproducing this though.

Is this a known issue? Has it already been addressed? Thanks!

4
Hi, I have a map that the player can zoom out on. That map has a ton of labels on it ... when zooming out the UILabels end up looking all aliased, is there any way to stop this happening? Thanks!

unzoomed:


zoomed:

5
NGUI 3 Support / Ways to optimize a grid of cards utilizing a pool
« on: August 31, 2016, 12:36:40 AM »
Hi all, I currently have a game where there are several scrollviews, each of which is a panel, that contain 'cards'. Each card has ~40widgets on it, each scrollview might have 20+ cards on it.

These cards can be created and destroyed rapidly (several a second) so I've been using a pooling system whereby cards removed from the scrollview are pushed into the pool and when needed pulled back out and reset with new spites / label contents etc.

This system is working well but, in searching for further optimizations, I discovered that setting the card gameobject active/inactive as it came from / went back to the pool was causing a heavy CPU penalty caused by all the UIWidget OnEnable() calls. A lot of those on drilling down seem to end in hundreds or thousands of UIWidget.PanelCompareFunc() calls.

If on the other hand I keep the gameobjects active while in the pool I end up with massively more calls to UIRect updates etc. which then offsets the benefits of not having to re-enable.

Is there an easier way to stash a collection of NGUI widgets in such a way that un-stashing it is performant?

I saw in another thread the mention that it might be more efficient to use lots of panels (one per card) instead of one panel with all the cards on. Is that the case?

Assuming it is, what's the best way to set up that per-card panel? Should it use clipping? Is there any benefit to then animating the panel around instead of the single child?

Thanks!

6
NGUI 3 Support / Adding Muti-touch gestures to NGUI
« on: August 20, 2016, 12:15:31 AM »
Hi all, this question has been asked a few times but after searching through everything I could find there still doesn't seem to be an easy way to add gestures like pinch-zoom to an NGUI project. My specific need is to add pinch-zoom to a map made up of hexagons where each is currently an NGUI sprite/button on a scroll view.

The closest I've come is finding https://github.com/TouchScript/TouchScript which a couple of years ago Aren wrote some integration for (http://www.tasharen.com/forum/index.php?topic=4984.msg56678#msg56678). The integration script requires an older version of TouchScript that's a few hundred commits behind current ... I tried updating it with 8.2 and Unity 5.4 (added below) which gets me a compiling project but then really no idea what to do next :)

Are there any easier solutions out there? What are devs using for mobile these days? Anyone have an example of how to detect pinches without breaking all of the other touch/mouse events?

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. // Download the appropriate TouchScript 8.2 package here:
  6. // https://github.com/TouchScript/TouchScript/releases/tag/8.2
  7.  
  8. using TouchScript;
  9. using TouchScript.InputSources;
  10.  
  11. /// <summary>
  12. /// Bridge script between TouchScript and NGUI. Simply attach this script to any game object.
  13. /// </summary>
  14.  
  15. public class TouchScriptNGUI : MonoBehaviour
  16. {
  17.         static public TouchScriptNGUI instance;
  18.  
  19.         /// <summary>
  20.         /// Whether the multi-touch should be enabled or not.
  21.         /// </summary>
  22.  
  23.         static public bool isEnabled
  24.         {
  25.                 get
  26.                 {
  27.                         if (instance != null) return instance.enabled;
  28.                         return PlayerPrefs.GetInt("Multitouch", 1) == 1;
  29.                 }
  30.                 set
  31.                 {
  32.                         PlayerPrefs.SetInt("Multitouch", value ? 1 : 0);
  33.                         if (instance != null) instance.enabled = value;
  34.                 }
  35.         }
  36.  
  37.         [System.NonSerialized] bool mActive = false;
  38.         [System.NonSerialized] BetterList<UICamera.Touch> mTouches = new BetterList<UICamera.Touch>();
  39.  
  40.         void Awake ()
  41.         {
  42.                 if (instance == null)
  43.                 {
  44.                         enabled = isEnabled;
  45.                         instance = this;
  46.                 }
  47.                 else Destroy(gameObject);
  48.         }
  49.  
  50.         void OnDestroy () { if (instance == this) instance = null; }
  51.  
  52.         void OnEnable ()
  53.         {
  54.                 mActive = true;
  55.                 NGUITools.AddMissingComponent<TouchManager>(gameObject);
  56.  
  57.                 UICamera.GetInputTouchCount = OnGetTouchCount;
  58.                 UICamera.GetInputTouch = OnGetTouch;
  59.  
  60.                 ITouchManager instance = TouchManager.Instance;
  61.                 instance.TouchesBegan += OnTouchBegan;
  62.                 instance.TouchesEnded += OnTouchEnded;
  63.                 instance.TouchesMoved += OnTouchMove;
  64.                 instance.TouchesCancelled += OnTouchCancel;
  65.  
  66.         }
  67.  
  68.         void OnDisable ()
  69.         {
  70.                 if (mActive)
  71.                 {
  72.                         mActive = false;
  73.                         UICamera.GetInputTouchCount = null;
  74.                         UICamera.GetInputTouch = null;
  75.                         ITouchManager instance = TouchManager.Instance;
  76.  
  77.                         if (instance != null)
  78.                         {
  79.                                 instance.TouchesBegan -= OnTouchBegan;
  80.                                 instance.TouchesEnded -= OnTouchEnded;
  81.                                 instance.TouchesMoved -= OnTouchMove;
  82.                                 instance.TouchesCancelled -= OnTouchCancel;
  83.                         }
  84.                         mTouches.Clear();
  85.                 }
  86.         }
  87.  
  88.         int OnGetTouchCount () { return mTouches.size; }
  89.         UICamera.Touch OnGetTouch (int index) { return mTouches[index]; }
  90.  
  91.         void OnTouchBegan (object sender, TouchEventArgs e)
  92.         {
  93.                 foreach (TouchPoint touch in e.Touches)
  94.                 {
  95.                         if (touch.Tags.HasTag(Tags.INPUT_MOUSE)) continue;
  96.  
  97.                         mTouches.Add(new UICamera.Touch()
  98.                                 {
  99.                                         phase = TouchPhase.Began,
  100.                                         fingerId = touch.Id,
  101.                                         position = touch.Position,
  102.                                         tapCount = 1
  103.                                 });
  104.                 }
  105.         }
  106.  
  107.         void OnTouchEnded (object sender, TouchEventArgs e)
  108.         {
  109.                 foreach (TouchPoint touch in e.Touches)
  110.                 {
  111.                         if (touch.Tags.HasTag(Tags.INPUT_MOUSE)) continue;
  112.  
  113.                         for (int index = 0; index < mTouches.size; ++index)
  114.                         {
  115.                                 UICamera.Touch t = mTouches[index];
  116.  
  117.                                 if (t.fingerId == touch.Id)
  118.                                 {
  119.                                         t.phase = TouchPhase.Ended;
  120.                                         t.position = touch.Position;
  121.                                         break;
  122.                                 }
  123.                         }
  124.                 }
  125.         }
  126.  
  127.         void OnTouchMove (object sender, TouchEventArgs e)
  128.         {
  129.                 foreach (TouchPoint touch in e.Touches)
  130.                 {
  131.                         if (touch.Tags.HasTag(Tags.INPUT_MOUSE)) continue;
  132.  
  133.                         for (int index = 0; index < mTouches.size; ++index)
  134.                         {
  135.                                 UICamera.Touch t = mTouches[index];
  136.  
  137.                                 if (t.fingerId == touch.Id)
  138.                                 {
  139.                                         t.position = touch.Position;
  140.                                         break;
  141.                                 }
  142.                         }
  143.                 }
  144.         }
  145.  
  146.         void OnTouchCancel (object sender, TouchEventArgs e) { OnTouchEnded(sender, e); }
  147.  
  148.         void LateUpdate ()
  149.         {
  150.                 int index = 0;
  151.  
  152.                 while (index < mTouches.size)
  153.                 {
  154.                         UICamera.Touch touch = mTouches[index];
  155.  
  156.                         if (touch.phase == TouchPhase.Ended)
  157.                         {
  158.                                 mTouches.RemoveAt(index);
  159.                         }
  160.                         else
  161.                         {
  162.                                 touch.phase = TouchPhase.Moved;
  163.                                 ++index;
  164.                         }
  165.                 }
  166.         }
  167. }

7
NGUI 3 Support / UIScrollView bug on using scrollwheel
« on: May 24, 2016, 09:32:10 AM »
The bug is:

* have a bouncy horizontal scrollview
* use the mouse wheel to scroll the contents so that they're squished against the side
* they'll smoothly animate back to the edge (as expected)
* then the contents jerk to a new position (for me ~100px offset from where they should be)

This looked like it was being caused by mScroll never dropping to 0 (I was seeing 3x10^-30 or something tiny like that). As a quick hack/fix I changed this in UIScrollView:

if (mMomentum.magnitude > 0.0001f || mScroll != 0)

to

if (mMomentum.magnitude > 0.0001f || Mathf.Abs(mScroll) > 0.0001f)

8
I'm adding a bunch of table items to a table where each item has a label set to resize height. I then call Reposition on the table and ... the end result is that the items all have incorrect spacing.

I believe the issue is that NGUI needs to calc the labels bounds, and then needs to update the surrounding frames of the labels (sprites set to update relative to the label on Update()) *before* it can know how to correctly space the items for the table.

I've hacked around this issue by running this after having repopulated the table:

  1. IEnumerator FixTable(){
  2.     yield return new WaitForEndOfFrame();
  3.     yield return new WaitForEndOfFrame();
  4.     table.Reposition();
  5. }

(the double frame wait is needed)

So, this works but it's pretty ugly, causes nasty flicker while waiting on the fames to sort out all the positions. Is there any way to not need this? Something like a force reset of all the bounds before calling Reposition() maybe?

9
Line 779 - I added a check on mDragStarted

if (restrictWithinPanel && mPanel.clipping != UIDrawCall.Clipping.None && mDragStarted){
    RestrictWithinBounds(dragEffect == DragEffect.None, canMoveHorizontally, canMoveVertically);
}

Reason for doing this is that I didn't want the scrollview to move around if I was just selecting something in it.

10
NGUI 3 Support / Unity 5.2 WebPlayer Issues on OSX
« on: September 22, 2015, 08:56:18 PM »
Hi, building one of the example scenes for web player in Unity 5.2 (or 5.2.1), using NGUI 3.9.2 will cause a couple of issues:

  • There's a bright pink triangle showing up bottom left. I eventually tracked this down to having the UIRoot's Camera component clear flags set to 'Depth only'. If this is set to 'don't clear' the pink triangle goes away.
  • If any controls are added using an atlas with an Unlit/Transparent Colored shader warning messages show up in the log: WARNING: Shader Unsupported: 'Hidden/UpdateDepthBuffer' - Pass '' has no vertex shader
    WARNING: Shader Unsupported: 'Hidden/UpdateDepthBuffer' - Setting to default shader.

I think these are both Unity issues and have reported the first as a bug, only happens on the OSX webplayer. Figured I'd also post it here as it looks at first glance like an NGUI issue as the default NGUI setup uses a Camera configured this way.

11
NGUI 3 Support / How to deal with really long strings?
« on: December 27, 2014, 04:18:27 PM »
SO I started building a manual save game import/export where the serialized save game string is ~45k characters. This seems to be too long to display in a UIInput/UILabel - what are good options for dealing with this scenario? Thanks!

Pages: [1]