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

Pages: [1] 2
1
I found the bug, and have made a hotfix for it.

At line 685 of UIInput:
  1. else if (mCached != text)
  2. {
  3.         mCached = text;
  4.         value = text;
  5. }
Changed to:
  1. else if (mCached != text)
  2. {
  3.         mCached = text;
  4. }
  5. else if (!mKeyboard.done || mKeyboard.active)
  6. {
  7.     value = mCached;
  8. }

This will cause the value to get set in the next frame instead of immediately after the text is changed.

The bug is that mKeyboard.text returns an empty string while it is actually closing down.
mKeyboard.done is still false and mKeyboard.active is still true, but no text value can be received.

EDIT: Tested it on iOS with Unity 5.0.1f1 - the bug was there as well, so it's a bug in Unity. The above code fixes it there as well.

2
The issue I'm having is pretty much the complete opposite of this post: http://www.tasharen.com/forum/index.php?topic=11493

I have a search feature that gets updated on input change: http://i.imgur.com/4tNtuMz.png

When you press outside (or even the hide keyboard button) the input field all changes are removed: http://i.imgur.com/cAggCVD.png
If you press Submit or OK on the keyboard itself, the changes get saved properly.

I'm using NGUI 3.8.2 and Unity Personal 5.0.1f1. I have tested it on Android 4.2.2 and 5.0.2 with the same result on both.
I also made an iOS build using Unity 5.0.0f4, where it works as usual (pretty sure it's just because of it being iOS and not the version, but will try to check it tomorrow).

I tried editing UIInput so Submit is called in OnDeselectEvent with no luck. It seems like mValue gets reset before the event is fired.

Any ideas?

3
Many thanks, it has completely fixed the issue.

Also, I noticed that it says "This message is awaiting approval by a moderator" at the top of my post - is this something I should be worried about?

4
NGUI 3 Support / Table reposition after populating prefab with anchors
« on: April 03, 2015, 10:57:46 AM »
Note: This message is awaiting approval by a moderator.
I'm currently populating a table with a prefabs created through simple code like this:

  1. Elev[] students = DatabaseManagement.Instance.GetStudentsInRoom(references.Id);
  2.  
  3. for (int i = 0; i < students.Length; i++)
  4. {
  5.         PoolManager.Instance.CreateNameTagPrefab(students[i], InfoPanelTable);
  6. }
  7.  
  8. StartCoroutine(DelayedReposition());

The method CreateNameTagPrefab instantiates a prefab using NGUITools.AddChild and adds it to the table. The prefab's labels are all updated with the values of the given student.

The coroutine consist of this:

  1. yield return null;
  2. InfoPanelTable.GetComponent<UITable>().Reposition();
  3. InfoPanelTable.transform.parent.GetComponent<UIScrollView>().ResetPosition();

The problem is that I have to delay the reposition by one frame in order to wait for anchors to update in the name prefab.

The ingame view looks like this.
This picture is an example of how it looks like with minimal info, but if the note is longer it will stretch a bit and look like this - so far, nothing is wrong.

The problem is that since it waits one frame it will flicker a bit: http://i.imgur.com/1GqZzNW.gif (primarily text overlapping due it them all being created in one place).

If I remove the frame delay it will reposition it to the original prefab size (before the anchors have been recalculated) and look like this (I'm not really sure why it goes all wonky either...)

Is there any way to force anchors to update instead of having to wait a frame?

5
NGUI 3 Support / Proposed change to TweenAlpha
« on: August 27, 2014, 05:02:08 PM »
In 3.7.0 TweenAlpha was changed so it also works with renderers.

However, the SpriteRenderer component has a color variable which can be used instead of changing the color in the material.

The changes:
- Added a SpriteRender variable after mMat called sRend.
- Added the following in the Cache() method:
  1. if (mRect == null)
  2. {
  3.     sRend = GetComponent<SpriteRenderer>();
  4.  
  5.     if(sRend == null)
  6.     {
  7.                 // get material
- Updated the value property to include checks for sRend:
  1. get
  2. {
  3.         if (!mCached) Cache();
  4.         if (mRect != null) return mRect.alpha;
  5.         if (sRend != null) return sRend.color.a; // <------
  6.         return mMat.color.a;
  7. }
  8. set
  9. {
  10.         if (!mCached) Cache();
  11.  
  12.         if (mRect != null)
  13.         {
  14.                 mRect.alpha = value;
  15.         }
  16.     else if(sRend != null)  // <------
  17.     {
  18.         Color c = sRend.color;
  19.         c.a = value;
  20.         sRend.color = c;
  21.     }
  22.         else
  23.         {
  24.                 Color c = mMat.color;
  25.                 c.a = value;
  26.                 mMat.color = c;
  27.         }
  28. }

6
NGUI 3 Support / Proposed change to sprite hover state
« on: August 27, 2014, 04:50:24 AM »
I use the built in sprite switching system when clicking on buttons - however, I currently do not use the hoversprite.

The setup is attached to this post.

The problem occurs when the user presses on a button and leaves the mouse over the button.
The state goes from Normal -> Hover -> Pressed -> Hover, but since the hoversprite has not been set, it will stay at the Pressed sprite until the user moves the mouse away from the button.

It could be fixed by setting the hoversprite to be equal to the normal sprite, but then I would need to update 2 values every time I would want to change 1 sprite.

To fix this, there's one line that needs to be changed in UIButton - line 266:
  1. Current:
  2. case State.Hover: SetSprite(hoverSprite); break;
  3.  
  4. Proposed fix (default to normal sprite if hoverSprite was not set):
  5. case State.Hover: SetSprite(string.IsNullOrEmpty(hoverSprite) ? mNormalSprite : hoverSprite); break;

7
NGUI 3 Support / Re: UIWrapContent stops working after getting disabled
« on: August 13, 2014, 07:54:34 AM »
Just tried separating it - works great! Thanks.

8
NGUI 3 Support / Re: UIWrapContent stops working after getting disabled
« on: August 13, 2014, 07:39:49 AM »
I just checked out the example - the reason the example works is because every Wrap Content is inside their own scroll view.
(I should probably do that as well, seems like a better way).

Here's how to reproduce the bug in the example scene:

- Duplicate the UIWrap Content gameobject that is inside any of the scroll views.
- Add this code to a button:

  1.     public GameObject View1;
  2.     public GameObject View2;
  3.  
  4.     private bool toggleState = false;
  5.  
  6.     public void OnClick()
  7.     {
  8.         toggleState = !toggleState;
  9.  
  10.         NGUITools.SetActive(View1, toggleState);
  11.         NGUITools.SetActive(View2, !toggleState);
  12.     }

- In the inspector, drag the two UIWrap Content GameObjects to the View1 and View2 variables.
- Start the game, press the button twice and it will stop wrapping in one of the gameobjects (the one placed in the View2 variable).

9
NGUI 3 Support / Re: UIButton.onClick non-invocable?
« on: August 12, 2014, 12:04:13 PM »
You can invoke the onClick this way: EventDelegate.Execute(close_btn.onClick);

However, if I understand your problem correctly, it would probably be better to just keep a reference of the UIPlayAnimation component and then activate the Play method through that variable when needed.

10
NGUI 3 Support / UIWrapContent stops working after getting disabled
« on: August 12, 2014, 11:06:12 AM »
I have a scrollview where the player can select a costume for their player.
I have 2 childs of the scrollview - a WrapContentMale object and a WrapContentFemale. Each of these 2 objects have the scripts UIWrapContent and UICenterOnChild.

I disable one of the 2 childs while the user is browsing, and if he wants to pick the other gender, there's a button to switch which one is disabled.
I disable them using NGUITools like so:

NGUITools.SetActive(AvatarSelectionCenterMale.gameObject, isMale);
NGUITools.SetActive(AvatarSelectionCenterFemale.gameObject, !isMale);

where the variables are references to the UICenterOnChild scripts.

It works great when you start the game, but after disabling the objects for the first time, the content will stop wrapping.

Video here: https://www.youtube.com/watch?v=ZYZMBheIYkw

The weird part is that the wrapper that was the first one to be disabled, will continue to work (in the video, the first one to be disabled was the female wrapper).

I have tried calling ResetPosition on the scrollview before and after disabling the objects, as well as use gameObject.SetActive instead of NGUITools, without success.

I'm using NGUI 3.6.8 and Unity 4.5.2f1.

11
NGUI 3 Support / Re: Bug in UIButtonColor when dragging
« on: July 30, 2014, 11:09:53 AM »
Ah kay, just figured I'd use UIButtonColor in this case since I only needed the color change and not the rest of the UIButton functionality.

The dragHighlight variable doesn't matter for me, I was just thinking about it generally. The reason I state that it won't fix it for everybody is because of line 225 of UIButton.
  1. if (isEnabled && (dragHighlight || UICamera.currentTouch.pressed == gameObject))
  2.         base.OnDragOver();
If dragHighlight is true but the pressed object isn't gameObject, it would still activate the base.OnDragOver, but since I copied the gameObject check the method will just stop there - dragHighlight would have no effect.

12
NGUI 3 Support / Re: Bug in UIButtonColor when dragging
« on: July 30, 2014, 09:45:22 AM »
Yeap, however, it won't be a good fix for everybody since the dragHighlight variable in UIButton won't be usable.

13
NGUI 3 Support / Bug in UIButtonColor when dragging
« on: July 29, 2014, 08:18:23 AM »
I have a couple of buttons set up with a UIButton and UIButtonColor that will invert colors when pressed (http://i.imgur.com/bPZbD2F.png)

If I press and hold on one of the buttons, and move the mouse over a different button, the new button label will change color to the pressed state and thereby hide the label (white text on white background).

Here's a video of it in action: http://gfycat.com/InstructiveSandyDragonfly

If I instead of UIButtonColor use UIButton, it works just fine, since it has some extra checks in the OnDragOver method (line 225):

  1. if (isEnabled && (dragHighlight || UICamera.currentTouch.pressed == gameObject))

At line 245 of UIButtonColor it doesn't check for this - it only checks for isEnabled.

14
NGUI 3 Support / Re: Inspector Look "Unified" bugs Anchors
« on: June 09, 2014, 05:38:35 AM »
It's easier to show, so I recorded a video.

http://youtu.be/H-8iVp5kzcY

It a completely clean project - the only thing imported is NGUI 3.6.3.

Turns out it is the same issue as @mishaps, I don't think it's the same as @sonicviz describes though.

15
NGUI 3 Support / Inspector Look "Unified" bugs Anchors
« on: June 06, 2014, 08:50:29 AM »
When switching to the inspector look "Unified" I am no longer able to edit Anchors freely - it will lock when I select anything other than "None" and I am unable to change any values.

Steps to reproduce:
1. Create an empty object in a 2D UI (have not tested with 3D, but I imagine it's the same).
2. Add a sprite to the object (Shift + Alt + S).
3. Change Anchor type to Unified and then change Anchor type to None.
4. Select another object in the Hierarchy and then select the newly created sprite: The Anchor type is still at Unified.
5. Change "Execute" to "OnEnable" - nothing happens, it is still "OnUpdate".
6. Change any of the anchor numeric values - nothing happens, they will be revert to the default value.

It will also happen with any existing objects, but this is the easiest way to test it.

I have NGUI version 3.6.2, have tried doing "Reimport All" and restarted Unity (which is v4.5.0f6).
Changing the inspector look to "Traditional" has fixed all problems.

Pages: [1] 2