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

Pages: 1 [2] 3 4 5
16
NGUI 3 Support / Re: NGUI Pickers - WebPlayer
« on: July 10, 2013, 10:24:25 AM »
Submitted to the Asset Store, should be out ( hopefully ) next week.

Here's the Unity Forums support thread, tutorial videos links included :

http://forum.unity3d.com/threads/189766-Soon-NGUI-Infinite-Pickers-A-complete-picker-framework


Cheers,

Gregzo

17
NGUI 3 Support / Re: NGUI Pickers - WebPlayer
« on: July 05, 2013, 05:49:35 PM »
Updated the WebPlayer : PickersForPickers WebPlayer

New :
Compound picker : as many labels or sprites per element as you need!
Full DateTime support!
Delegates!
Design patterns!

Picker Heaven...

Last chance for suggestions.

Cheers,

Gregzo

18
NGUI 3 Support / Re: NGUI Pickers - WebPlayer
« on: July 05, 2013, 01:03:06 PM »
Just a little update - feel free to add requests as I'm nearing completion.

-Date picker now supports time as well, date and time prefab available. GetCurrentDateTime() to retrieve the selected date and time as a System.DateTime struct.

-Following ArenMook's suggestion, dropped compatibility with NGUI free. Upside : delegates are now used, resulting in better performance and flexibility.

-Delegate implementation means it is now easy to build compound pickers : picker element can now contain any number of sprites or labels. 3 sprites, 2 labels - 4 labels, 2 sprites - whatever you need is possible. Prefab included features 2 sprites and 1 label : item sprite, price label, and currency sprite. Think : orc armour boots sprite (item sprite), 4 (price label) gold coins (currency sprite).

-Tested performance on iPhone 4 ( not 4gs ) : 60 fps with the demo scene, lots of pickers in there!

-Code structure improvement : the PickerManagerBase class implements the Template Method pattern - meaning you can learn about design patterns, but also easily extend the class for custom behaviours. Design Patterns are definitely in!

Cheers,

Gregzo

19
Thanks Aren. I will do as you suggest.

Please pace yourself on the new Unity GUI, I'd like to sell a few pickers before it is released!

Many thanks for your understanding,

Gregzo


20
NGUI 3 Support / Re: NGUI Pickers - WebPlayer
« on: July 05, 2013, 01:15:40 AM »
@Nicki

Thanks for the compliment!

I now need to clean up and comment the code, organise prefabs, write a readme, and submit. Hopefully by early next week!

Would 10$ be too much? The only other asset I have in the asset store is 5$, and that ended up being a bit cheap considering the work it took and the amount of copies sold...

Cheers,

Gregzo

21
NGUI 3 Support / Re: How to trigger event when SpringPanel finishes?
« on: July 05, 2013, 01:10:12 AM »
My understanding from reading the code is that UICenterOnChild.onFinished is a relay to SpringPanel.onFinished. Why do you need to access SpringPanel.onFinished directly? Whenever UICenterOnChild.Recenter is fired, it resets SpringPanel.onFinished delegate to make it point to it's own onFinished...

22
NGUI 3 Support / Re: Shake the UI?
« on: July 04, 2013, 02:30:23 PM »
Just shake your UI's parent object, it's not the most efficient but works.

If your parent obj has a UIAnchor, disable the UIAnchor component before shaking ( it locks the transform's position ).






23
Hi,

NGUI free doesn't come with UICenterOnChild, so I've made my own version, UICenterOnChildManual, which centers on a specific Transform as opposed to finding the center-most transform itself.
It's very much a stripped down version of the original, adapted for compatibility and use with my pickers.
Is it OK to include it in my asset store package?
Here it is :

  1. using UnityEngine;
  2.  
  3.         /// <summary>
  4.         /// Manual version of NGUI's UICenterOnChild -stripped down and adapted for compatibility with NGUI free
  5.         /// </summary>
  6. public class UICenterOnChildManual : MonoBehaviour
  7. {
  8.         UIDraggablePanel mDrag;
  9.         GameObject mCenteredObject;
  10.         UIPanel mDragPanel;
  11.  
  12.         /// <summary>
  13.         /// Recenter the draggable list on targetTrans.
  14.         /// </summary>
  15.  
  16.         public void CenterOnChild( Transform targetTrans )
  17.         {
  18.                 if (mDrag == null)
  19.                 {
  20.                         mDrag = NGUITools.FindInParents<UIDraggablePanel>(gameObject);
  21.                        
  22.                         mDragPanel = gameObject.GetComponent ( typeof ( UIPanel ) ) as UIPanel;
  23.  
  24.                         if (mDrag == null)
  25.                         {
  26.                                 Debug.LogWarning(GetType() + " requires " + typeof(UIDraggablePanel) + " on a parent object in order to work", this);
  27.                                 enabled = false;
  28.                                 return;
  29.                         }
  30.                 }
  31.                 if (mDragPanel == null) return;
  32.  
  33.                 // Calculate the panel's center in world coordinates
  34.                 Vector4 clip = mDragPanel.clipRange;
  35.                 Transform dt = mDragPanel.cachedTransform;
  36.                 Vector3 center = dt.localPosition;
  37.                 center.x += clip.x;
  38.                 center.y += clip.y;
  39.                 center = dt.parent.TransformPoint(center);
  40.  
  41.                 // Offset this value by the momentum
  42.                 mDrag.currentMomentum = Vector3.zero;
  43.  
  44.                 // Figure out the difference between the chosen child and the panel's center in local coordinates
  45.                 Vector3 cp = dt.InverseTransformPoint(targetTrans.position);
  46.                 Vector3 cc = dt.InverseTransformPoint(center);
  47.                 Vector3 offset = cp - cc;
  48.  
  49.                 // Offset shouldn't occur if blocked by a zeroed-out scale
  50.                 if (mDrag.scale.x == 0f) offset.x = 0f;
  51.                 if (mDrag.scale.y == 0f) offset.y = 0f;
  52.                 if (mDrag.scale.z == 0f) offset.z = 0f;
  53.  
  54.                 // Spring the panel to this calculated position
  55.                 SpringPanel.Begin(mDrag.gameObject, dt.localPosition - offset, 8f);
  56.         }
  57. }

Cheers,

Gregzo

24
NGUI 3 Support / Re: NGUI Pickers - WebPlayer
« on: July 04, 2013, 09:12:02 AM »
New build available :
GregzosPickerHeaven

New features :
-Date picker in 6 languages ( request yours! )
-Number picker
-Scroll wheel support
-Scroll buttons

Fixes :
-Better momentum feel
-Any drag speed is now handled

Suggestions still welcome, releasing soon!

Cheers,

Gregzo

25
NGUI 3 Support / Re: NGUI Pickers - WebPlayer
« on: July 04, 2013, 03:50:37 AM »
@hrlarsen

Hi and thanks for the input!

Will implement number pickers now - elements recycling logic is in a seperate class from content logic, so it'll be pretty easy to specify a min, a max, and a step ( all even numbers from 25 to 39247 for example ).

Will test on iOS today, and give news.

26
NGUI 3 Support / Re: NGUI Pickers - WebPlayer
« on: July 04, 2013, 03:25:00 AM »
Scroll wheel support and scroll buttons added.

Any other suggestions ?

27
NGUI 3 Support / Re: best practices for NGUI across scenes?
« on: July 04, 2013, 03:24:12 AM »
When you load a scene, Unity destroys everything that is not marked DontDestroyOnLoad and loads your new scene fully, including potential duplicates.

  1. DontDestroyOnLoad ( this.gameObject )
affects the object and all it's children. Similarly, Destroy ( gameObject ) will destroy the object and all it's children. Destroy ( this ) will simply destroy the component ( the script ), not the GameObject.

So, for a persistent UI, parent all your UI to one object that is set to DontDestroyOnLoad. When you work on your levels, it can be handy to have the UI in every scene ( play level 5 directly, for example ), but that can lead to duplicates, hence my second script above : check if the UI exists in the scene, if it does, self destruct.

Hope it helps!


28
NGUI 3 Support / Re: best practices for NGUI across scenes?
« on: July 03, 2013, 03:56:26 PM »
If you need the UI to persist through scenes, why not set it to DontDestroyOnLoad?

Simplest example : attach the following script to your UICamera in the first loaded level, no need for UI's in other scenes :

  1. public class DontDestroyOnLoadThis : Monobehaviour
  2. {
  3.      void Awake ()
  4.      {
  5.           DontDestroyOnLoad ( this.gameObject );
  6.      }
  7. }

Or pseudo-singleton version, on the camera in every scene :
  1. public class DontDestroyOnLoadUI : Monobehaviour
  2. {
  3.      static DontDestroyOnLoadUI _instance;
  4.  
  5.      void Awake ()
  6.      {
  7.           if ( _instance != null )
  8.           {
  9.                 Destroy ( this.gameObject );
  10.                 return;
  11.           }
  12.  
  13.           DontDestroyOnLoad ( this.gameObject );
  14.           _instance = this;
  15.      }
  16. }
This last example would allow having a UI in every scene for ease of development, but a single persistent UI when actually playing the game.

29
NGUI 3 Support / Re: NGUI Pickers - WebPlayer
« on: July 03, 2013, 06:59:29 AM »
Hi sonicviz,

Thanks for the feedback.

I have to figure out a way to deal with the scroll wheel - fire UICenterOnChild.Recenter at the right moment.

About fast scroll arrows : what behaviour exactly are you thinking of? Hold to scroll fast, or click to forward n elements?
NGUI already has good scroll bar support, maybe on desktop that would be more appropriate than pickers...

Cheers,

Gregzo

30
NGUI 3 Support / NGUI Pickers - WebPlayer
« on: July 03, 2013, 04:51:39 AM »
Hi to all,

I finally had enough free time to give my pickers project a bit of work.

-Horizontal and vertical
-Momentum
-Infinite
-Labels, sprites, compound objects
-Add / remove elements dynamically
-Receive selection callbacks as index or content ( label text, spritename )
-Recycles 5 objects for best performance ( no instantiate )

Here's a web player demo
WebPlayer

I plan to release it on the Asset Store soon, comments and suggestions are welcome!

Known issue : doesn't handle well very fast dragging. The workaround I can think of involves modifying UIDragPanelContents, which really isn't suitable for a publicly available asset. Any ideas to clamp drag values without changing NGUI classes ? [EDIT] : Issue solved, will post a new build soon. Pickers can now handle any speed.

Cheers,

Gregzo

Pages: 1 [2] 3 4 5