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

Pages: 1 [2] 3
16
NGUI 3 Support / Re: Passing Instance References Via EventDelegate
« on: June 13, 2014, 03:54:50 AM »
Bleah, I can't get this to work. Can anyone help me with a functional example please?
Thank you.

 :'(

17
NGUI 3 Support / Re: NGUI Iphone 4 (iOS6) performance
« on: May 28, 2014, 06:54:32 AM »
You can set the target frame rate inside the Awake function. Something like:

  1. void Awake () {
  2.     Application.targetFrameRate = 60;
  3. }
  4.  

As for the VSync Count option you will find it in the Unity menu.

Edit > Project Settings > Quality




18
This is the behaviour that I am talking about:

NORMAL


BUGGY



How can this be fixed? Any quick solutions?

19
There is something weird happening when using the new 2D UI event type for the camera and the NGUI > Extras > Switch to 2D Colliders function. This can be reproduced with the following steps:
  • Open from Examples > Example 7 - Scroll View (Panel)
  • Change Event Type to 2D UI

  • Use Switch to 2D Colliders function


Notice that when starting the drag the scroll view gets all "jumpy". After switching back to 3D UI and 3D Box Colliders everything works fine.

20
NGUI 3 Support / Atlas Maker error in Unity 4.5
« on: May 27, 2014, 07:56:06 AM »
I am receiving an error when trying to create an atlas with NGUI, that doesn't stop the creation of it but it displays every time I create/update an atlas. Right now I'm having the situation described here: http://www.tasharen.com/forum/index.php?topic=9548.0

I hope that I can fix it.


21
NGUI 3 Support / Re: Passing Instance References Via EventDelegate
« on: May 19, 2014, 01:28:14 PM »
I have method like:
  1. public void DoStuff(CustomType arg) {
  2.       // do something with arg
  3. }
  4.  

and on the button I run:
  1. EventDelegate.Parameter a = new EventDelegate.Parameter();
  2. a.obj = this;
  3. a.field = "someField";
  4.  
  5. EventDelegate del = EventDelegate.Add(button.onClick, DoStuff);
  6. del.parameters = new EventDelegate.Parameter[] { a };
  7.  

Maybe I am confused, what does "someField" represents?

22
NGUI 3 Support / Re: Passing Instance References Via EventDelegate
« on: May 19, 2014, 09:10:35 AM »
UITweener.curent always tells you which tween triggered the callback, even without having to pass anything. If you need other custom parameters specified via a script, you can do it like so:
  1. EventDelegate.Parameter a = new EventDelegate.Parameter();
  2. a.obj = this;
  3. a.field = "someField";
  4.  
  5. EventDelegate.Parameter b = new EventDelegate.Parameter();
  6. b.obj = this;
  7. b.field = "anotherField";
  8.  
  9. EventDelegate del = EventDelegate.Add(insc.GetComponent<TweenPosition>().onFinished, AddToScore);
  10. del.parameters = new Parameter[] { a, b };


When I try to do this I receive different errors:

  1. The best overloaded method match for `EventDelegate.Add(System.Collections.Generic.List<EventDelegate>, EventDelegate)' has some invalid arguments
  2. Argument `#2' cannot convert `method group' expression to type `EventDelegate'
  3. Property or indexer `EventDelegate.parameters' cannot be assigned to (it is read only)
  4.  

Also I can not use:
  1. del.parameters = new Parameter[] { a, b };
  2.  

it throws an error
  1. The name 'Parameter' does not exist in the current context.
  2.  

and I replaced it with

  1. del.parameters = new EventDelegate.Parameter[] {delTroop};
  2.  


What I am trying to do is to set the highlighted part (red) from code.

23
How can I remove all event delegates from UIButton in code? Basically I just want to clear all of them.

24
Nevermind. It was actually working, however, my initialize function was being called again after the OnApplicationQuit call. I still don't know why, but I have fixed that problem.

Can I ask how did you fixed that issue? (my initialize function was being called again after the OnApplicationQuit call)

Thanks.

25
NGUI 3 Support / Re: Disappearing of AlphaClip option
« on: April 10, 2014, 08:34:37 AM »
Because in some usage cases it's visible like semitransparent vertical or horizontal line.
Please remove that restriction in future updates.

This is true, it happens especially when two elements with contrasting colors are next to each other. It is visible.

26
NGUI 3 Support / Re: Pivot position in UITable
« on: April 01, 2014, 05:32:13 AM »
Another update

  1. //----------------------------------------------
  2. //            NGUI: Next-Gen UI kit
  3. // Copyright © 2011-2014 Tasharen Entertainment
  4. //----------------------------------------------
  5.  
  6. using UnityEngine;
  7. using System.Collections.Generic;
  8.  
  9. /// <summary>
  10. /// All children added to the game object with this script will be arranged into a table
  11. /// with rows and columns automatically adjusting their size to fit their content
  12. /// (think "table" tag in HTML).
  13. /// </summary>
  14.  
  15. [AddComponentMenu("NGUI/Interaction/Table (Pivot)")]
  16. public class UITablePivot : UIWidgetContainer
  17. {
  18.     public delegate void OnReposition();
  19.    
  20.     public enum Direction
  21.     {
  22.         Down,
  23.         Up,
  24.     }
  25.  
  26.     public enum Pivot
  27.     {
  28.         Left,
  29.         Center,
  30.         Right
  31.     }
  32.    
  33.     public enum Sorting
  34.     {
  35.         None,
  36.         Alphabetic,
  37.         Horizontal,
  38.         Vertical,
  39.         Custom,
  40.     }
  41.    
  42.     /// <summary>
  43.     /// How many columns there will be before a new line is started. 0 means unlimited.
  44.     /// </summary>
  45.    
  46.     public int columns = 0;
  47.    
  48.     /// <summary>
  49.     /// Which way the new lines will be added.
  50.     /// </summary>
  51.    
  52.     public Direction direction = Direction.Down;
  53.    
  54.     /// <summary>
  55.     /// How to sort the grid's elements.
  56.     /// </summary>
  57.    
  58.     public Sorting sorting = Sorting.None;
  59.  
  60.  
  61.     /// <summary>
  62.     /// Table pivot
  63.     /// </summary>
  64.     ///
  65.     public Pivot pivot = Pivot.Left;
  66.  
  67.     /// <summary>
  68.     /// Whether inactive children will be discarded from the table's calculations.
  69.     /// </summary>
  70.    
  71.     public bool hideInactive = true;
  72.    
  73.     /// <summary>
  74.     /// Whether the parent container will be notified of the table's changes.
  75.     /// </summary>
  76.    
  77.     public bool keepWithinPanel = false;
  78.    
  79.     /// <summary>
  80.     /// Padding around each entry, in pixels.
  81.     /// </summary>
  82.    
  83.     public Vector2 padding = Vector2.zero;
  84.    
  85.     /// <summary>
  86.     /// Delegate function that will be called when the table repositions its content.
  87.     /// </summary>
  88.    
  89.     public OnReposition onReposition;
  90.  
  91.     protected UIPanel mPanel;
  92.     protected bool mInitDone = false;
  93.     protected bool mReposition = false;
  94.     protected List<Transform> mChildren = new List<Transform>();
  95.    
  96.     // Use the 'sorting' property instead
  97.     [HideInInspector]
  98.     [SerializeField]
  99.     bool
  100.         sorted = false;
  101.    
  102.     /// <summary>
  103.     /// Reposition the children on the next Update().
  104.     /// </summary>
  105.    
  106.     public bool repositionNow { set { if (value) { mReposition = true; enabled = true; } } }
  107.    
  108.     /// <summary>
  109.     /// Returns the list of table's children, sorted alphabetically if necessary.
  110.     /// </summary>
  111.    
  112.     public List<Transform> children
  113.     {
  114.         get
  115.         {
  116.             if (mChildren.Count == 0)
  117.             {
  118.                 Transform myTrans = transform;
  119.                 mChildren.Clear();
  120.                
  121.                 for (int i = 0; i < myTrans.childCount; ++i)
  122.                 {
  123.                     Transform child = myTrans.GetChild(i);
  124.                     if (child && child.gameObject && (!hideInactive || NGUITools.GetActive(child.gameObject)))
  125.                         mChildren.Add(child);
  126.                 }
  127.                
  128.                 if (sorting != Sorting.None || sorted)
  129.                 {
  130.                     if (sorting == Sorting.Alphabetic) mChildren.Sort(UIGrid.SortByName);
  131.                     else if (sorting == Sorting.Horizontal) mChildren.Sort(UIGrid.SortHorizontal);
  132.                     else if (sorting == Sorting.Vertical) mChildren.Sort(UIGrid.SortVertical);
  133.                     else Sort(mChildren);
  134.                 }
  135.             }
  136.             return mChildren;
  137.         }
  138.     }
  139.    
  140.     /// <summary>
  141.     /// Want your own custom sorting logic? Override this function.
  142.     /// </summary>
  143.    
  144.     protected virtual void Sort (List<Transform> list) { list.Sort(UIGrid.SortByName); }
  145.    
  146.     /// <summary>
  147.     /// Positions the grid items, taking their own size into consideration.
  148.     /// </summary>
  149.    
  150.     protected void RepositionVariableSize (List<Transform> children)
  151.     {
  152.         float xOffset = 0;
  153.         float yOffset = 0;
  154.        
  155.         int cols = columns > 0 ? children.Count / columns + 1 : 1;
  156.         int rows = columns > 0 ? columns : children.Count;
  157.        
  158.         Bounds[,] bounds = new Bounds[cols, rows];
  159.         Bounds[] boundsRows = new Bounds[rows];
  160.         Bounds[] boundsCols = new Bounds[cols];
  161.        
  162.         int x = 0;
  163.         int y = 0;
  164.        
  165.         for (int i = 0, imax = children.Count; i < imax; ++i)
  166.         {
  167.             Transform t = children[i];
  168.             Bounds b = NGUIMath.CalculateRelativeWidgetBounds(t, !hideInactive);
  169.            
  170.             Vector3 scale = t.localScale;
  171.             b.min = Vector3.Scale(b.min, scale);
  172.             b.max = Vector3.Scale(b.max, scale);
  173.             bounds[y, x] = b;
  174.            
  175.             boundsRows[x].Encapsulate(b);
  176.             boundsCols[y].Encapsulate(b);
  177.            
  178.             if (++x >= columns && columns > 0)
  179.             {
  180.                 x = 0;
  181.                 ++y;
  182.             }
  183.         }
  184.        
  185.         x = 0;
  186.         y = 0;
  187.        
  188.         for (int i = 0, imax = children.Count; i < imax; ++i)
  189.         {
  190.             Transform t = children[i];
  191.             Bounds b = bounds[y, x];
  192.             Bounds br = boundsRows[x];
  193.             Bounds bc = boundsCols[y];
  194.            
  195.             Vector3 pos = t.localPosition;
  196.             pos.x = xOffset + b.extents.x - b.center.x;
  197.             pos.x += b.min.x - br.min.x + padding.x;
  198.            
  199.             if (direction == Direction.Down)
  200.             {
  201.                 pos.y = -yOffset - b.extents.y - b.center.y;
  202.                 pos.y += (b.max.y - b.min.y - bc.max.y + bc.min.y) * 0.5f - padding.y;
  203.             }
  204.             else
  205.             {
  206.                 pos.y = yOffset + (b.extents.y - b.center.y);
  207.                 pos.y -= (b.max.y - b.min.y - bc.max.y + bc.min.y) * 0.5f - padding.y;
  208.             }
  209.            
  210.             xOffset += br.max.x - br.min.x + padding.x * 2f;
  211.            
  212.             t.localPosition = pos;
  213.            
  214.             if (++x >= columns && columns > 0)
  215.             {
  216.                 x = 0;
  217.                 ++y;
  218.                
  219.                 xOffset = 0f;
  220.                 yOffset += bc.size.y + padding.y * 2f;
  221.             }
  222.         }
  223.  
  224.         RepositionPivot(children);
  225.     }
  226.  
  227.     /// <summary>
  228.     /// Recalculate the position of all the elements of the table, to change the pivot
  229.     /// </summary>
  230.  
  231.    
  232.     public void RepositionPivot(List<Transform> children) {
  233.         float Width = 0;
  234.         if (pivot != Pivot.Left)
  235.             Width = NGUIMath.CalculateRelativeWidgetBounds(transform).size.x;
  236.        
  237.         for (int i = 0, imax = children.Count; i < imax; ++i) {
  238.             Transform t = children [i];
  239.             Vector3 pos = t.localPosition;
  240.             if (pivot == Pivot.Center)
  241.                 pos.x -= Width / 2 + padding.x;
  242.             else if (pivot == Pivot.Right)
  243.                 pos.x -= Width + padding.x;
  244.             else if (pivot == Pivot.Left)
  245.                 pos.x -= padding.x;
  246.            
  247.             t.localPosition = pos;
  248.         }
  249.     }
  250.    
  251.     /// <summary>
  252.     /// Recalculate the position of all elements within the table, sorting them alphabetically if necessary.
  253.     /// </summary>
  254.    
  255.     [ContextMenu("Execute")]
  256.     public virtual void Reposition ()
  257.     {
  258.         if (Application.isPlaying && !mInitDone && NGUITools.GetActive(this))
  259.         {
  260.             mReposition = true;
  261.             return;
  262.         }
  263.        
  264.         if (!mInitDone) Init();
  265.        
  266.         mReposition = false;
  267.         Transform myTrans = transform;
  268.         mChildren.Clear();
  269.         List<Transform> ch = children;
  270.         if (ch.Count > 0) RepositionVariableSize(ch);
  271.        
  272.         if (keepWithinPanel && mPanel != null)
  273.         {
  274.             mPanel.ConstrainTargetToBounds(myTrans, true);
  275.             UIScrollView sv = mPanel.GetComponent<UIScrollView>();
  276.             if (sv != null) sv.UpdateScrollbars(true);
  277.         }
  278.        
  279.         if (onReposition != null)
  280.             onReposition();
  281.     }
  282.    
  283.     /// <summary>
  284.     /// Position the grid's contents when the script starts.
  285.     /// </summary>
  286.    
  287.     protected virtual void Start ()
  288.     {
  289.         Init();
  290.         Reposition();
  291.         enabled = false;
  292.     }
  293.    
  294.     /// <summary>
  295.     /// Find the necessary components.
  296.     /// </summary>
  297.    
  298.     protected virtual void Init ()
  299.     {
  300.         mInitDone = true;
  301.         mPanel = NGUITools.FindInParents<UIPanel>(gameObject);
  302.     }
  303.    
  304.     /// <summary>
  305.     /// Is it time to reposition? Do so now.
  306.     /// </summary>
  307.    
  308.     protected virtual void LateUpdate ()
  309.     {
  310.         if (mReposition) Reposition();
  311.         enabled = false;
  312.     }
  313. }
  314.  
  315.  

27
How can I determine when the scroll view has reached the dragging bounds? For example I am still dragging but there is nothing more to drag (no spring) is there any event for that? OnDragFinish doesn't apply because I am still dragging and I wanna do something inside that situation.

I hope I am making any sense with what I am saying.  :o

Cheers!

28
NGUI 3 Support / Re: Custom colliders?
« on: March 20, 2014, 07:08:50 AM »
Ok, so I managed to do something and I have no idea if it's the right way, but it works. Basically I used box colliders and rotated them in 3D space to have some kind of isometric view. I am building a 2D game and I guess I didn't thought of using 3D related stuff.




Is that the right way to do it?

29
NGUI 3 Support / Custom colliders?
« on: March 20, 2014, 05:41:54 AM »
Hello all, I am pretty new to NGUI and Unity and I've just started my first project and I have a question related to colliders (I think).


I am trying to make some tiles (isometric) and I'm not really sure how to add proper interaction, I made them as UISprites and attached Box Colliders, but as you can see in the picture the colliders overlap. How to treat this situation?

Do the Polygon Colliders 2D work with NGUI? I've tried to use the UIHitAlphaTest from http://www.tasharen.com/forum/index.php?topic=7824.0 and it works, but the thing is that the tiles should be invisible and I guess that won't work with UIHitAlphaTest.

I hope I'm being clear on what I'm trying to do/say.

Thank you.

30
NGUI 3 Support / Re: NGUI Binding system release date
« on: March 12, 2014, 05:50:56 AM »
+1 on that

Pages: 1 [2] 3