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

Pages: [1] 2 3
1
NGUI 3 Support / Re: Assigning string to GUIStyle
« on: August 21, 2014, 06:55:37 AM »
Very cool! I can see this window being invaluable.

2
NGUI 3 Support / Assigning string to GUIStyle
« on: August 20, 2014, 10:32:46 AM »
Hey guys

I was reading through some NGUI code when I hit a bunch of lines that look like:

  1. if (mBlueDot == null) mBlueDot = "sv_label_1";

Where mBlueDot is a GUIStyle.

This is absolutely fascinating to me on a bunch of levels, because I didn't know you could assign strings to GUIStyles, and I don't know what the operation here is actually intending to do.

Can someone please explain this to me?

Thanks,
Ves

3
NGUI 3 Support / UIScrollView - Disable bounds caching
« on: June 27, 2014, 03:34:42 AM »
Hey guys

We have a scenario where we have a UILabel with a UIInput as an immediate child to a UIScrollView panel.

In editor, changing the text value of the label causes the UIScrollView bounds (the orange box) to be recalculated, which is ideal. However, while running the scene, the bounds do not seem to update.

I'm not sure why this behaviour would be different while playing, but it seems to me that the reason the bounds aren't being recalculated is because of the following property in UIScrollView:

  1.         /// <summary>
  2.         /// Calculate the bounds used by the widgets.
  3.         /// </summary>
  4.  
  5.         public virtual Bounds bounds
  6.         {
  7.                 get
  8.                 {
  9.                         if (!mCalculatedBounds)
  10.                         {
  11.                                 mCalculatedBounds = true;
  12.                                 mTrans = transform;
  13.                                 mBounds = NGUIMath.CalculateRelativeWidgetBounds(mTrans, mTrans);
  14.                         }
  15.                         return mBounds;
  16.                 }
  17.         }

I can't imagine it being particularly expensive to calculate the bounds for a few rects. Perhaps we could have the option to disable caching bounds in the inspector?

For now I believe I can work around this by calling InvalidateBounds() as needed.

Thanks,
Ves

4
NGUI 3 Support / Re: Flickering when setting anchors at runtime
« on: June 19, 2014, 03:21:35 AM »
Nice and easy, works perfectly. Thanks Aren!

5
NGUI 3 Support / Flickering when setting anchors at runtime
« on: June 18, 2014, 11:50:51 AM »
Hey guys

This is probably an easy one. At runtime we instantiate UIRect prefabs and set anchors, transform, depth and size. It looks like there is an initial frame where the rect occupies the full screen, producing a "flicker" effect.

I assume that the parent orients the rect correctly on the following Update call. I'm wondering if there's a way to schedule an immediate re-orientation?

Thanks,
Ves

6
NGUI 3 Support / Re: Mac UIInput issues
« on: June 16, 2014, 11:09:52 AM »
And I'm sorry, I can't believe I left this out, but this was specifically happening in webplayer builds. Tested in both Chrome and Safari.

7
NGUI 3 Support / Re: Mac UIInput issues
« on: June 16, 2014, 11:08:47 AM »
We're currently on Unity Pro 4.5.0f6 and NGUI 3.5.9

8
NGUI 3 Support / Mac UIInput issues
« on: June 16, 2014, 06:01:24 AM »
Hey guys

I'm having trouble getting text input on Mac devices. The problems range from being unable to type into UIInputs to being unable to delete/backspace inputs.

I've done some googling and I've hit a number of threads from the past couple years:

2010 (potentially related?)
http://forum.unity3d.com/threads/gui-textfield-focus-kills-input-getkeydown-on-mac-but-not-on-pc.66714/

2012
http://www.tasharen.com/forum/index.php?topic=2324.0

2013
http://www.tasharen.com/forum/index.php?topic=4010.0

The general consensus seems to be that it's a problem with Unity, and that a mythical fix will eventually arrive. Unfortunately, given the age of the problem, I don't have much faith in this being patched any time soon.

Was anyone ever able to find a fix or workaround for these problems?

Thanks,
Ves

9
NGUI 3 Support / Re: SpriteSelector not selecting sprites
« on: June 11, 2014, 07:01:48 AM »
Sorry Aren, I know my variable names are inconsistent with those in UISprite. The names in my PropertyDrawer represent those found in my PropertyAttribute.

Reading SpriteSelector it seems to be completely agnostic to any property paths, so I still don't think the naming is a problem here.

I just spent some time re-reading my code a bunch of times to make sure this is true, and I found this stupid mistake:

Old -
  1. SpriteSelector.Show((string spriteName) => SelectSprite(serializedObject, sp, sp.stringValue));

New -
  1. SpriteSelector.Show((string spriteName) => SelectSprite(serializedObject, sp, spriteName));

Sorry for wasting your time!

10
NGUI 3 Support / SpriteSelector not selecting sprites
« on: June 10, 2014, 04:21:31 AM »
Hi all

I'm trying to bash together a SpriteData PropertyAttribute with a custom property drawer:



It's not a perfect copy of the atlas and sprite fields that NGUI draws in the inspector, but it's at a stage where it's working pretty well.

The only problem I have is that I can't select sprites. I'm using the following code to build the "Sprite" button:

  1.         if (GUI.Button(new Rect(position.x, position.y,
  2.                                 PREFIX_BUTTON_WIDTH, position.height), "Sprite"))
  3.         {
  4.                 NGUISettings.atlas = atlas.objectReferenceValue as UIAtlas;
  5.                 NGUISettings.selectedSprite = sp.stringValue;
  6.                 SpriteSelector.Show((string spriteName) => SelectSprite(serializedObject,
  7.                                                                                         prop.FindPropertyRelative("m_SpriteName"),
  8.                                                                                        sp.stringValue));
  9.         }
  10.  
  11.         /// <summary>
  12.         ///     Sprite selection callback function.
  13.         /// </summary>
  14.         private void SelectSprite(SerializedObject serializedObject, SerializedProperty serializedProperty,
  15.                                   string spriteName)
  16.         {
  17.                 Debug.Log(spriteName);
  18.  
  19.                 serializedObject.Update();
  20.                 serializedProperty.stringValue = spriteName;
  21.                 serializedObject.ApplyModifiedProperties();
  22.                 NGUISettings.selectedSprite = spriteName;
  23.         }

When I press the "Sprite" button I get the SpriteSelector window, but when I click on sprites I get a debugged sprite name of "":



Furthermore, I can see that the typical green rect is not drawn on the sprites in the editor window, indicating to me that I don't seem to be making any meaningful selection.

Opening sprite selector from UISprite:



Opening sprite selector from custom property drawer:



I'm attaching the property and the drawer in case anyone wants to take a look. It's pretty short but the drawer gets messy.

If anyone has any ideas on how I can get the SpriteSelector to work, I'd love to hear them.

Thanks,
Ves


11
NGUI 3 Support / Disable UIInput
« on: June 04, 2014, 05:28:58 AM »
Hey guys

I'm looking into disabling the UIInput component. I've come accross this thread:

http://www.tasharen.com/forum/index.php?topic=8381.msg39561#msg39561

Disabling the collider sounds like it would work for mouse events, but what happens with keyboard events, such as tabbing?

What is the most comprehensive way of preventing user interaction while keeping the widget visible?

Thanks,
Ves

12
NGUI 3 Support / UIPanel and Uniform Anchor
« on: March 11, 2014, 02:04:35 PM »
Hey guys

I'm having trouble finding information on this.

I want to be able to set a UIPanel to Unified anchor mode and have it follow a GameObject. Is this possible?

From reading the source it looks like I need to set a clipping mode, but none of the clipping modes seem to do exactly what I need.

Thanks,
Ves

13
NGUI 3 Support / Unreliable anchoring
« on: March 11, 2014, 07:50:40 AM »
Hi all

I'm extremely close to getting my anchoring working correctly, but this one last thing is causing me to lose sleep.

I have a perspective camera, I have an orthographic camera in my menu hierarchy, and I have some GameObjects that are rotating around a (invisible) sphere:



I'm instantiating some UITextures via NGUITools.AddChild(uiRoot, prefab) and using SetAnchor to make them follow my GameObjects.

This is what it should look like:

(Perspective camera, gizmos)


(Both cameras)


However, when I first start my scene I get this (Yellow lines show where the anchor is with respect to the UIRect):

(perspective camera)


(both cameras)


Now, my UITextures are hooked up, via click event, to a mechanism that essentially calls SetAnchor a bunch of times. By clicking all UITextures in turn I can "fix" the anchoring:

http://i.gyazo.com/5f7e4cb9db1a502ab7baefcdb0ee8f55.mp4

Alternatively, moving the GameObjects does not fix the anchoring:

http://i.gyazo.com/968cdfa52ef6ff05c18ce05c04cfe825.mp4

Can anyone offer any suggestions as to how I can fix my anchoring?

From reading the NGUI source, if I was to hazard a guess, I would say the issue would be to do with the way UIRect looks up the camera for each side.

14
Thanks for the tips ArenMook, I'm starting to get somewhere!

http://gyazo.com/6716dcaff90f8c638bc77d2814578028

15
Hey ArenMook

I need to be able to get a given UIRect to follow a GameObject in screen space. I understand I can do this by using the "Unified" anchor mode, but I want to be able to set this up programatically. There are a few parts I'm a little stuck with:

1) "Unified" is just an abstraction in the editor script. How do I get the same behaviour programatically?
2) What should the UIRect be parented to in the UI hierarchy while it follows the GameObject?
3) My GameObject is presented in a perspective camera while my UIRects are in an orthagraphic camera in the UI hierarchy. Will the UIRect correctly follow its target?

Apologies if I've completely misunderstood how anchoring works.

Thanks,
Ves

Pages: [1] 2 3