Author Topic: [Suggestion] some features  (Read 2499 times)

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
[Suggestion] some features
« on: July 05, 2014, 08:54:27 PM »
1. Tooltip on mobile (OnTooltip )
tne OnTooltip is designed for mouse.
could you add a new trigger type which is called by press?
that is for mobile platform

2. UISwitch
the UIToggle only active/deactive the foreground sprite,
could you add UISwitch which is inheritance UIToggle, which switch the sprites instead of set foreground sprite active state?
UIToggle: on-> sprite active, background active, off-> sprite deactive, background active
UISwitch: on-> sprite active, background deactive, off-> sprite deactive, background active

3. Tweens by multi inputs
here is a example for TweenPosition => TweenPositions
  1. using UnityEngine;
  2.  
  3. public class TweenPositions : UITweener
  4. {
  5.         // change 1
  6.         //public Vector3 from;
  7.         //public Vector3 to;
  8.         // --
  9.         public Vector3[] toPositions;
  10.         // --change 1
  11.  
  12.         [HideInInspector]
  13.         public bool worldSpace = false;
  14.  
  15.         Transform mTrans;
  16.         UIRect mRect;
  17.  
  18.         public Transform cachedTransform { get { if (mTrans == null) mTrans = transform; return mTrans; } }
  19.  
  20.         public Vector3 value
  21.         {
  22.                 get
  23.                 {
  24.                         return worldSpace ? cachedTransform.position : cachedTransform.localPosition;
  25.                 }
  26.                 set
  27.                 {
  28.                         if (mRect == null || !mRect.isAnchored || worldSpace)
  29.                         {
  30.                                 if (worldSpace) cachedTransform.position = value;
  31.                                 else cachedTransform.localPosition = value;
  32.                         }
  33.                         else
  34.                         {
  35.                                 value -= cachedTransform.localPosition;
  36.                                 NGUIMath.MoveRect(mRect, value.x, value.y);
  37.                         }
  38.                 }
  39.         }
  40.  
  41.         void Awake () { mRect = GetComponent<UIRect>(); }
  42.  
  43.         // chage 2
  44.         //protected override void OnUpdate (float factor, bool isFinished) { value = from * (1f - factor) + to * factor; }
  45.         // --
  46.         protected override void OnUpdate (float factor, bool isFinished)
  47.         {
  48.                 float blockSize = 1f / ( toPositions.Length - 1 );
  49.                 int index = (int)( factor / blockSize );
  50.                 float realFactor = factor % blockSize;
  51.                 if( index == toPositions.Length - 1 )
  52.                 {
  53.                         index -= 1;
  54.                         realFactor = blockSize;
  55.                 }
  56.                
  57.                 value = toPositions[index] * (blockSize - realFactor) /  blockSize + toPositions[index+1] * realFactor / blockSize ;
  58.         }
  59.         // --chage 2
  60.  
  61.         // change 3
  62. //      static public TweenPosition Begin (GameObject go, float duration, Vector3 pos)
  63. //      {
  64. //              TweenPosition comp = UITweener.Begin<TweenPosition>(go, duration);
  65. //              comp.from = comp.value;
  66. //              comp.to = pos;
  67.         // --
  68.         static public TweenPositions Begin (GameObject go, float duration, Vector3 pos, params Vector3[] extraPos)
  69.         {
  70.                 TweenPositions comp = UITweener.Begin<TweenPositions>(go, duration);
  71.                 System.Collections.Generic.List<Vector3> temp = new System.Collections.Generic.List<Vector3>( extraPos );
  72.                 temp.Insert( 0, pos );
  73.                 temp.Insert( 0, comp.value );
  74.  
  75.                 comp.toPositions = temp.ToArray();
  76.         // --change 3
  77.                 if (duration <= 0f)
  78.                 {
  79.                         comp.Sample(1f, true);
  80.                         comp.enabled = false;
  81.                 }
  82.                 return comp;
  83.         }
  84. }
  85.  
  86.  

4. Note for scripting
some use of NGUI of me are wrong.i found that when i asked some question or browsed the NGUI forum.
e.g. i should call NGUITools.AddChild instead of Instantiate the prefab by myself.
the fact is , users don't know the rules (and sometimes the rules were changed after version update ), could you add a scripting note page and list the roles for users?

« Last Edit: July 05, 2014, 09:14:21 PM by gyd »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [Suggestion] some features
« Reply #1 on: July 05, 2014, 10:59:49 PM »
1. OnTooltip is a convenience notification more than anything. If you hover your mouse over an object for X seconds, you get that notification. What you do with it is then up to you -- such as displaying a tooltip. You can do exactly the same thing in OnPress without the need for OnTooltip.

2. That's quite simple to do, and doesn't need to be a toggle at all. It can literally be achieved by a script that like 5 lines long: 2 public sprite names, OnClick() function that swaps between them. UIToggle is ideal if you want a smooth transition. Then your background sprite is your "off" state and your foreground sprite is your "on" state. The "on" state will cover up your "off" state, without the need to turn it off.

3. I don't quite follow this. Tweens by multi inputs? Why specify a list of positions? If you are getting this complicated, create an animation, not a tween. Tweens are for going from point A to point B. Animations can be anything.

4. I will be doing that in the near future, yes. I'm also going to create a better video covering scripting with NGUI, with the dynamically populating scroll views being one example. I will certainly mention AddChild a few times there.

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: [Suggestion] some features
« Reply #2 on: July 05, 2014, 11:41:59 PM »
thx for the reply.
in fact i did the work of #1~#3, but i think it would be perfect if the 3 suggestions are built-in.
and more:

#2 i think it's ok to be built-in because these are similar to UISlider & UIProgressBar.
#3.1 the most important idea of that is "set a list of positions DYNAMICALLY", so i could not create a animation for that.
#3.2 the reason is, sometimes i wanna tween a ui group from points, e.g. move into screen from top-right to top, and move to center. anyway, i did it by the TweenPositions example code.
it's ok because it might be an individual case, if you consider tweens don't have to support multi-input.
« Last Edit: July 06, 2014, 06:58:03 PM by gyd »

PoN

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 111
    • View Profile
Re: [Suggestion] some features
« Reply #3 on: July 06, 2014, 12:38:53 AM »
3. I don't quite follow this. Tweens by multi inputs? Why specify a list of positions? If you are getting this complicated, create an animation, not a tween. Tweens are for going from point A to point B. Animations can be anything.

probably he talks about a sequence of Tween ?
Worked on Doc&DogAge Of Fury 3D. Actually working on WarMach.