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

Pages: [1]
1
NGUI 3 Support / Re: UInput stopped working on Unity 5.2.0f2 (mac)
« on: September 14, 2015, 08:49:09 AM »
Closing and reopening the editor does seem to fix the issue for a single keypress, but then subsequent keyboard input once again stops working.  Not sure if this issue is the exact same as the one mentioned in the known issues list or not.

2
NGUI 3 Support / Re: why,popuplist postion error
« on: November 21, 2014, 10:18:18 AM »
Thanks!  That fixed it for me.

3
NGUI 3 Support / Re: How can i anchor a UIPanel ?
« on: November 20, 2014, 12:04:23 PM »
If you turn on soft-clipping on the panel it has the normal anchoring features doesn't it?  I'm kinda curious on the answer to this too, but my experience is that the panel by default is 'full screen' with no anchor settings needed or available but as soon as you turn on soft-clip you get the normal anchor options just like an object with a UIWidget.

4
NGUI 3 Support / Re: why,popuplist postion error
« on: November 18, 2014, 09:21:11 AM »
I was able to nail down a duplicatable process I think.

Using Unity 4.6RC2 and NGUI 3.7.6, open "Example 0 - Control Widgets" and move either of the two popups near the top of the screen and see the following when activated:



5
NGUI 3 Support / Re: why,popuplist postion error
« on: November 17, 2014, 09:55:12 AM »
I'm seeing this positioning issue too actually.  Can't exactly say how to duplicate it, but I've tracked it down to the offset math at the very bottom of UIPopupList.cs.  Basically, the transform position is correct up until the line: t.localPosition += offset;

This used to work a few version ago so not sure what might have changed... hope this might provide some clue though.

This is what I'm seeing (in this case 'offset' ends up being (0,-50, 0) which is the exact cause of my mystery gap here):


6
NGUI 3 Support / Re: Invisible UIButton that can still be clicked
« on: August 21, 2014, 11:57:38 AM »
alpha == .001 should still fire event and be invisible

7
NGUI 3 Support / Re: "simple" coordinate question
« on: July 23, 2014, 11:18:54 AM »
Ok... the below actually does work to position my widgets as I had originally described above. 

I have no idea why what I was doing above didn't work though.  (and I'd really like some advice on what I was doing wrong if anyone has a minute to digest all that I wrote... although the below code makes sense to me on a very basic level, it seems all that coordinate nonsense is something I need to understand at some point and obviously don't at all currently...)

  1. Vector3 crap = new Vector3(leftPanel.transform.localPosition.x + leftPanel.width / 2, leftPanel.transform.localPosition.y);
  2. TweenPosition.Begin(rightPanel.gameObject, 2f, crap);

8
NGUI 3 Support / Re: "simple" coordinate question
« on: July 23, 2014, 11:09:54 AM »
Been banging on this a bit more... I think I had some math wrong in the last code where I was trying to derive the -1:1 coordinate given via NGUI into some form of 'viewport' (which I believe go from [0,0] in bottom left hand corner to [1,1] in top right) or 'screen' coordinates (which I believe go from [0,0] in bottom left corner to [width px,height px] in top right).

I believe this works to 'normalize' the NGUI coordinate, then convert that value into a screen position and a world position. 

  1. Bounds lBounds = NGUIMath.CalculateAbsoluteWidgetBounds(leftPanel.transform);
  2. print(lBounds);
  3.  
  4. float xPoint = (lBounds.center.x + (lBounds.extents.x / 2));
  5. float normalX = (1 + xPoint) / 2;
  6.  
  7. //center vertically:
  8. float yPoint = lBounds.center.y;
  9. float normalY = (1 + yPoint) / 2;
  10.  
  11. Vector3 normalPos = new Vector3(normalX, normalY);
  12. print(normalPos);
  13. Vector3 screenPos = this.core.root.UICamera.ViewportToScreenPoint(normalPos);
  14. print(screenPos);
  15. Vector3 worldPos = this.core.root.UICamera.ScreenToWorldPoint(screenPos);
  16. print(worldPos);
  17.  
  18. TweenPosition.Begin(rightPanel.gameObject, 2f, worldPos)

Unfortunately, throwing normalPos, screenPos, or worldPos at the TweenPosition.Begin method still results in incorrect positioning (although printing the various coordinates I'm deriving seems to result in plausible values... if I'm interpreting everything correctly)... I think at this point I just don't get which of the many various coordinate systems and values TweenPosition is expecting.

9
NGUI 3 Support / "simple" coordinate question
« on: July 23, 2014, 09:15:32 AM »
So I think this question is probably a result of my own basic lack of understanding of the various coordinate systems in 3D programming... but I'll pose it here as my specific application is related to moving around some NGUI widgets.

So, lets say I've got two UISprite rectangles on the screen.  One is on the left hand side, the other is on the right.  I simply want to programatically move the right hand rectangle so it is horizontally centered on the right edge of the first triangle.

Before:
xxxx     
x  x      zzz
x  x      zzz
xxxx


After:
xxxx
x zzz
x zzz
xxxx


So... it seems from various posts I've found that part of the key here is to use NGUIMath.CalculateAbsoluteWidgetBounds to get my widget rectangle coordinates.  Then I think I should be able to derive the target screen point to pass to TweenPosition.Begin on my right hand rectangle.

On button press I'm doing the following:
  1. Bounds lBounds = NGUIMath.CalculateAbsoluteWidgetBounds(leftWidget.transform);
  2. print(lBounds);

This generates the following log output:
  1. Center: (-0.8, 0.0, 0.0), Extents: (0.4, 1.0, 0.0)

So, I'm deducing from this output that we are in some kind of -1:1 coordinate system. (Does this have a name one could Google to get educated?  It's sort of normalized but not, because < 0 so I'm not sure what I'm even looking at here.)  If my assumption is correct, it seems I should be able to figure out the right edge of my left box by taking:


  1. xPos = (center + (width / 2)) * Screen.width / 2
  2. [aka]
  3. xPos = (-0.8 + (0.4 / 2)) * Screen.width / 2

... but I think this is the basic spot where I'm getting off track.

When I:
  1. TweenPosition.Begin(rightWidget.gameObject, 1f, new Vector3(xPos, 0f))
The box moves a bit too far to the left and overshoots it's target.  Any ideas?  Is there any easier way to translate the result of CalculateAbsoluteWidgetBounds into something usable by TweenPosition?

10
NGUI 3 Support / Re: Drag & Drop first item padding
« on: July 07, 2014, 11:32:33 AM »
Here's my hack fix... found that the UIDragScrollView was being enabled too soon so it was registering a drag instead of just reordering items. 

(All changes to vanilla noted with 'XX' below... please let me know if you might plan to incorporate something like this in a future release, I'd much rather use your base class instead of my hack subclass)

Thanks!

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class XXUIDragDropItem : UIDragDropItem {
  5.  
  6.   override protected void OnDragDropRelease (GameObject surface)
  7.         {
  8.                 if (!cloneOnDrag)
  9.                 {
  10.                         mTouchID = int.MinValue;
  11.  
  12.                         // Re-enable the collider
  13.                         if (mButton != null) mButton.isEnabled = true;
  14.                         else if (mCollider != null) mCollider.enabled = true;
  15.  
  16.                         // Is there a droppable container?
  17.                         UIDragDropContainer container = surface ? NGUITools.FindInParents<UIDragDropContainer>(surface) : null;
  18.  
  19.                         if (container != null)
  20.                         {
  21.                                 // Container found -- parent this object to the container
  22.                                 mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;
  23.  
  24.                                 Vector3 pos = mTrans.localPosition;
  25.                                 pos.z = 0f;
  26.                                 mTrans.localPosition = pos;
  27.                         }
  28.                         else
  29.                         {
  30.                                 // No valid container under the mouse -- revert the item's parent
  31.                                 mTrans.parent = mParent;
  32.                         }
  33.  
  34.                         // Update the grid and table references
  35.                         mParent = mTrans.parent;
  36.                         mGrid = NGUITools.FindInParents<UIGrid>(mParent);
  37.                         mTable = NGUITools.FindInParents<UITable>(mParent);
  38.  
  39.                         // Re-enable the drag scroll view script
  40.                         if (mDragScrollView != null)
  41.                           /*XX*  mDragScrollView.enabled = true; */
  42.                           /*XX*/ StartCoroutine(this.activateScrollViewLater());
  43.  
  44.                         // Notify the widgets that the parent has changed
  45.                         NGUITools.MarkParentAsChanged(gameObject);
  46.  
  47.                         if (mTable != null) mTable.repositionNow = true;
  48.                         if (mGrid != null) mGrid.repositionNow = true;
  49.  
  50.                 }
  51.                 else NGUITools.Destroy(gameObject);
  52.         }
  53.  
  54.   /*XX ADD****************************/
  55.   IEnumerator activateScrollViewLater() {
  56.     yield return new WaitForEndOfFrame();
  57.     mDragScrollView.enabled = true;
  58.   }
  59.   /*XX ADD END************************/
  60.  
  61. }
  62.  

11
NGUI 3 Support / Re: Drag & Drop first item padding
« on: July 07, 2014, 07:52:56 AM »
Right, so just so we are on the same page...  does that mean you agree there is an issue and might take a look at it, or do you think this is a corner case I've hit that I should piece together a workaround for myself?  (Either answer is ok... just trying to deduce what the direction was from your last reply so I'm not waiting when I should be coding  :) )

12
NGUI 3 Support / Re: Drag & Drop first item padding
« on: July 03, 2014, 11:10:55 AM »
I've created a video demonstrating the issue.  What I'm doing here is dragging a few items out of the left hand side column so it's no longer 'full' then I show how dragging items to the first position in that column seems to inflate the padding on that first cell.

http://youtu.be/TZhyO7SUcEE

13
NGUI 3 Support / Drag & Drop first item padding
« on: July 01, 2014, 01:17:17 PM »
In Example 11, if you grab items and drop them in the 'first' slot at the top of the list you'll see the padding on that first cell get larger and larger as you drop more items in "slot one". 

I assume the scroll position of the scroller is being incremented unnecessarily when items are dropped here.  Is there a fix for this short of listening for an event manually and resetting the scroller position?

Pages: [1]