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

Pages: [1] 2
1
NGUI 3 Support / Re: Many Warnings after upgrading to 2017.1
« on: November 02, 2017, 06:46:31 PM »
This was driving me nuts so I changed UIGrid line 283 to:

  1. void OnValidate () { if (!Application.isPlaying && NGUITools.GetActive(this)) Invoke(nameof(Reposition),0.01f); }

2
NGUI 3 Support / Re: UILabel Resize Freely truncates content
« on: August 25, 2017, 04:13:44 AM »
Perfect! Thank you so much :)

3
NGUI 3 Support / Re: UILabel Resize Freely truncates content
« on: August 24, 2017, 04:21:11 AM »
Hi Aren, thanks for the reply ... the issue is that I need the resize freely behavior - I want to have a label centered but with an icon anchored to the labels right. I guess the alternative hack would be to calc the content width and adjust the icon position in code but would prefer to have a code-free solution to something this standard!

What would your recommendation be for taking this on?

4
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?

5
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)

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

8
guess those image urls didn't work, take 2:

unzoomed:


zoomed:

9
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:

10
NGUI 3 Support / Re: Ways to optimize a grid of cards utilizing a pool
« on: November 04, 2016, 05:59:41 PM »
PanelCompareFunc is just a sort function. It simply compares integers inside (depth values). The less widgets you have per panel, the fewer calls to PanelCompareFunc you will have. You can't avoid having those calls entirely, but the cost of doing so is minimal, so not sure why you are even bringing it up. All I can think of is maybe you did a deep profile, which would be a mistake to base your findings on. Deep profile adds a static amount of overhead to every function call, no matter how small the function's execution time may be. So 1 call to a function that takes 1 ms to execute may add 0.01 ms, making it 1.01 ms in deep profile. Now 1000 calls to a function that takes 0.0001 ms to execute would normally be 0.0001 * 1000 = 0.1 ms, but in deep profile that becomes (0.0001 + 0.01) * 1000 = 10.1 ms, leading you to think that there is a problem when in fact there isn't.

Yes I was using dee profile, had no idea about the profiler adding overhead to each call ... that drastically changes things! Thanks for the heads-up!

11
NGUI 3 Support / Re: Ways to optimize a grid of cards utilizing a pool
« on: September 20, 2016, 05:21:58 PM »
I guess I was really asking two questions - how to create a performant pool of objects and best practices for dealing with collections of moving components.

The issue with disabling the widget is that on re-enabling hundreds to thousands of UIWidget.PanelCompareFunc() calls are generated.

For the second question it sounds like I could benefit from moving my cards to a panel for each, thanks for the tip.

12
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!

13
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. }

14
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)

15
The issues start happening when you have table items who's sizes are dependent on the dynamic label. For example a label might have a background sprite that is sized to be 10px bigger than the label on all edges.

In this scenario, in order to correctly space the table items the order needs to be :

* update dynamic label size
* update dependent object size
* update table positioning

What actually seems to happen is undefined ... in my project the dependent object size was getting updated after the table repositioning and changing script execution order wasn't altering that behavior.

Pages: [1] 2