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.

Topics - Nubeh

Pages: [1]
NGUI 3 Support / implement shake animation on anchored button
« on: September 04, 2014, 07:46:04 AM »
I implemented my gui with different buttons that are all anchored and stretched in order to adapt to multiple screens resolutions. I want to add a shake animation to some of them to be triggered via a script but I was wondering what's the best way to approach this because the anchor script will always keep my button element at the same position. Is it possible to use the NGUI Tween class without disabling the anchor component? Thanks.

NGUI 3 Support / strange sprites artefacts at the borders
« on: August 26, 2014, 09:16:00 AM »
I'm experiencing some weird issues with some of my sprites. I have all of them packed in an atlas and every single image is set to Texture with Alpha is Transparency. It happens that some of the sprites when used in a view have some thin lines around the border. It's strange because it happens only with some of the sprites. I tried to add some transparent border to such sprites and then setting the border in the sprite editor to 2px but it doesn't change. The effect is also very inconsistent, sometimes only some instances of the sprite have artefacts, sometimes the artefacts are only visible when deployed on device but maybe they are visible on an iPhone but not Android. Any idea what the reason could be? Thank you.

I have 3 labels with a fixed width and height where I change the text (always one word only) dynamically. Because I don't know the length of the word beforehand I set the label to ShrinkContent. The problem now is that when a word in label 1 is short and the one in label 2 is long then the dimensions of the font for the two labels is different.
Is there a way to set the smallest font size among all 3 labels so that the text inside them looks all the same size?


NGUI 3 Support / UIAnchor and UIStretch
« on: July 22, 2014, 02:48:56 AM »
I have a question about these two deprecated components. I'm working on mobile and I really like these two components because it seems to me that it's much easier with them to create a button that is padded 10% from the right of the screen and stretched 40% of the screen width. With the new anchor system shown in the tutorials it's not really clear to me how to do that quickly and there's all those pixels values that I don't really need because my gui has to work on many different devices.

I was wondering if it's not recommended to use UIAnchor and UIStretch for performance reasons and also if there's a way to not have the "run only once" activated. I noticed that if "run only once" is active some of the elements are not placed or stretched correctly when I switch between views.
If "run only once" is active I notice in the profiler that the performance is pretty bad sometimes and that a lot of CPU is spent in the anchors and stretch updates functions.

NGUI 3 Support / UITexture randomly gets changed into a UISprite
« on: July 10, 2014, 02:35:59 AM »
Hi there,
I'm using 3.6.6 and I've tried to create a UITexture with a button script and collider. The reason I use a UITexture is because the image for the button is downloaded from the internet, saved in memory and then loaded when needed. I noticed though that regularly, and it's not clear to me when, the UITexture component is replaced by a UISprite, thus making my game crash when I try to access the mainTexture parameter that UISprite doesn't have obviously.
Is it NGUI that changes that when I build my project for iOS or Android? Or is it Unity that does that? Again, I have no idea when this happens exactly, but after a bit I notice the error and I see that the UITexture has become a UISprite class.
Any idea why that could be? Is it because I attached a button component to it?


I have a slider component and I would like to create a rectangle sprite on top of the slider's background image. I want this sprite to cover a certain area of the slider, let's say from 50% to 70%. How to I get the positioning and sizing to do that?
I know that the thumb image when positioned at those percentages will give me that position but how can that be calculated with code? I tried to get the slider's background widget width but the value is somehow much longer that on screen. How can I get the total width of my slider?


I'm trying to create a pointer using a NGUI sprite. What I want to achieve is to have a sprite that points towards the direction of an object  by moving along the screen borders (the object it points is outside the screen on a 3d plane).

The problem I have is that I don't know how to convert the intersection points on screen with my NGUI camera viewport position. I have 2 cameras, one looking down a 3D world and one used for NGUI. I can calculate the point along the screen borders for the main camera, but I don't know how to convert the world position to the NGUI UICamera where all my GUI stuff is (including my pointer sprite).

Here is an example of how I calculate the intersection point between the left border of the screen and the line from the middle of the screen and the target position (I then check if there's an intersection with other borders of the screen if none is found with the left border):

                      Vector2 intersection = new Vector2();
         Vector2 topLeft = new Vector2(MainController.instance.visibleArea.TOP_LEFT.x, MainController.instance.visibleArea.TOP_LEFT.z);
         Vector2 bottomLeft = new Vector2(MainController.instance.visibleArea.BOTTOM_LEFT.x, MainController.instance.visibleArea.BOTTOM_LEFT.z);
         Vector2 topRight = new Vector2(MainController.instance.visibleArea.TOP_RIGHT.x, MainController.instance.visibleArea.TOP_RIGHT.z);
         Vector2 bottomRight = new Vector2(MainController.instance.visibleArea.BOTTOM_RIGHT.x, MainController.instance.visibleArea.BOTTOM_RIGHT.z);
         Vector2 targetPos = new Vector2(target.x, target.z);
         Vector2 screenCenter = MainController.instance.screenCenter;
         //Debug.LogWarning("SCREEN CENTER: "+screenCenter.x+", "+screenCenter.y);
         //left border
         if(Utils.LineIntersection(topLeft, bottomLeft, targetPos, screenCenter, ref intersection)){

                              //TODO: convert intersection point to NGUI camera screen position


NGUI 3 Support / Dynamic fonts issue with Unity 4.3
« on: November 29, 2013, 03:45:30 AM »
After I updated to Unity 4.3 (and yesterday update to 4.3.1 didn't solve the things) I have an issue with my fonts. Basically instead of taking my font (which was working before) now the font is Arial. The weird thing is that I was seeing Arial fonts also in the Editor until yesterday. When I updated to Unity 4.3.1 and that allowed the Editor to render the correct font I'm using. But if I deploy to iOS or Android the font is again Arial.

For the dynamic font I have simply imported a .ttf file in Unity and used that without creating a Font with NGUI.

I don't know if this is related but after updating NGUI to the latest version (3.0.6) I also get these error message in the console,

Unlit/Text doesn't have a clipped shader version for SoftClip
Debug:LogError(Object) (at Assets/Scripts/Debug.cs:58)
UIDrawCall:CreateMaterial() (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:303)
UIDrawCall:RebuildMaterial() (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:324)
UIDrawCall:UpdateMaterials() (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:347)
UIDrawCall:Set(BetterList`1, BetterList`1, BetterList`1, BetterList`1, BetterList`1) (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:453)
UIPanel:SubmitDrawCall(UIDrawCall) (at Assets/NGUI/Scripts/UI/UIPanel.cs:1049)
UIPanel:Fill() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1004)

Anybody has this problem as well? Thanks.

NGUI 3 Support / version 3.0.6 conflicts with SpriteManager
« on: November 28, 2013, 11:02:05 AM »
I updated to 3.0.6 (I opened a new scene, deleted the NGUI folder and downloaded it again from the Assets Store). Unfortunately it doesn't compile because it says that Sprite has no definition of textureSize. I think the problem is that I have among my plugins SpriteManager which already includes a Sprite class and I'm not sure if NGUI tries to get that one instead of the Unity new Sprite class by mistake.

Is there a way to solve this without renaming the Sprite class of SpriteManager?


I have a scrollview with some images in it and I want to show a button under the images when one is pressed. I created a button object and when one of the images is clicked I anchor the button to the bottom of the image. This works fine except that if I scroll my view the clipping area doesn't affect my button because it's not "inside" the grid.

I tried to parent the object to the clicked image and then anchor it but I got a weird behaviour: the button's Y position keeps diminishing over time (thus going outside the screen) after doing that for some reason. I tried to parent the button and then call Reposition() on the grid but it didn't work, same behaviour.

So what's the correct way to parent a button object to a scrollview element dynamically?


NGUI 3 Support / Scrollview with clickable buttons in it
« on: October 29, 2013, 05:34:41 AM »
I'm trying to build a scrollable list with some buttons in it but I ran into a weird issue: my buttons are not clickable. For some reason the outline panel behind the buttons grid gets the collider hit all the time and I don't know why.

I have buttons in other parts of the scene and they work fine...the only difference with the buttons I have in the scrollview is that those buttons have the UIDrag Panel Contents script attached so that they can be used to drag the panel.

Did someone managed to make something like this and make it work?


NGUI 3 Support / Buttons sprites auto-adjust to match
« on: October 29, 2013, 04:51:25 AM »
There's something a bit annoying about NGUI buttons: if you move the anchor of a button or switch between iOS to Android build all the buttons colliders position gets ruined. Of course I can select each button one by one and chose NGUI -> Add Collider to reset the position, but it gets tedious when my scene has 30-50 buttons.

I noticed that the new NGUI 3.0.3 has an 'auto-adjust to match' option on sprites...but in case of buttons I don't need the background to have a collider, I need the Button object to have one in order to listen for onPress events.

Is there a way to having the colliders resizing and repositioning themselves on button objects automatically?

NGUI 3 Support / UILabel text with color bug in 3.0.3?
« on: October 28, 2013, 07:45:15 AM »
Hi there,
I had this code working last week where I was setting the text on a UILabel using a color variable for the text color like this:

myLabel.text = "["+color+"]"+mytext+"[-]"

but after updating to NGUI 3.0.3 I get this error:

ArgumentOutOfRangeException: startIndex + length > this.length
Parameter name: length
System.String.Substring (Int32 startIndex, Int32 length) (at /Applications/buildAgent/work/c514da0c8183631c/mcs/class/corlib/System/String.cs:356)
NGUIText.WrapText (System.String text, UnityEngine.Font font, Int32 size, FontStyle style, Int32 width, Int32 height, Int32 maxLines, Boolean encoding, System.String& finalText) (at Assets/NGUI/Scripts/Internal/NGUIText.cs:414)
UILabel.ProcessText (Boolean legacyMode) (at Assets/NGUI/Scripts/UI/UILabel.cs:800)
UILabel.ProcessText () (at Assets/NGUI/Scripts/UI/UILabel.cs:762)
UILabel.ProcessAndRequest () (at Assets/NGUI/Scripts/UI/UILabel.cs:296)

I also enabled on the UILabel the ShrinkContent option with Crisp Always.

Does anybody else have the same issue?

Pages: [1]