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

Pages: [1]
NGUI 3 Support / NGUI Unity 2017.3 ScrollRect Support
« on: January 14, 2018, 04:05:10 PM »
After upgrade to Unity 2017.3, it looks like scrollrects never register clicks anymore (they always interpret drag events), and we have myriad issues with colliders.

Whilst we can debug NGUI to deal with this (and the result will probably still be more usable than the disaster that is official Unity UI with dynamic layouts, endless srolling and integrated 3D models in the UI), it would be great to know if anyone is actively using NGUI with 2017.3, and/or if there will be an official update.

NGUI 3 Support / Moving back to NGUI - Unity Sprite Support
« on: October 13, 2017, 05:07:24 PM »
After 18 months of using Unity UI, we are strongly considering reverting to NGUI for our next app. We do relatively complex app layout (nested panels, etc as opposed to just game menus) and Unity UI seems to be a broken minefield of undocumented scrollview and autolayout nastiness, augmented by a bunch of half arsed community scripts on unity forums by people who really don't understand what they're doing.

The only thing about Unity UI we like is the sprite atlas system (just rect sprites are fine, but we like the flexibility of Unity's texture format choices when packing for optimization, rather than trying to manually create e.g. PVRTC, 16-bit and 32-bit atlases.) We also like the intuitive-ness of using the hierarchy to control sprite draw order. Is it now possible to use Unity Sprites throughout your NGUI widgets and use the hierarchy to manage depth, or is this not advised?

NGUI 3 Support / atlases caching redundant references to prefabs.
« on: January 18, 2015, 04:41:46 PM »
We are trying to optimize memory usage by ensure that specific screens (UIPanels) are only loaded, and thus there atlases are only loaded, when we require them.

I've tried this with various versions of NGUI, and there seems to be some way in which UISprites preserve incorrect references to atlases. It is extremely difficult to permanently remove all references to an atlas in the build player such that the atlas does not get loaded at all.

For example, we have one scene where we have three large atlases, each references by separate UIPanels. We have moved each panel to a separate Prefab, which is resource.Load()ed. We have also confirmed in the editor at runtime that right-clicking the unused atlases and selecting "Find References in Scene" returns no unexpected references, even after the prefab is instantiated. We have also confirmed that dragging the prefab into the scene and checking for references has no dangling references.

However, when building the player (for iPhone), all prefabs still incorrectly drag in all atlases.

I can give more details, and yes I do really know my stuff about Unity memory management, but would like to ask whether your aware of sprites caching redundant references to atlases before going into more detail.

There used to be a very similar case in NGUI 2.x (and it may still exist in 3.x) where the following sequence:

1. Switch an atlas to a reference.
2. Reference a half-sized version of the atlas.

Would still leave references to the full-sized atlas, although I'm not sure this is related, since in that case I suspect what happened was the Reference Atlas still held a dangling material reference.

I am quite happy to hand-edit prefab files to remove atlas references if that's required.


NGUI 3 Support / Redundant references to UIAtlas Prefabs
« on: January 15, 2015, 01:24:41 AM »
Our scene seems to contain many dead references to atlases from bits of UI that may at some time have referenced that atlas.

We are trying to clean the scene up so that we can Resource.Load() prefabs of sub-screens, and have the atlases for those sub-screens pulled in by sprite references in that screen only. However, in all cases right-clicking in project view and "find references in scene" shows many UI objects referencing the atlas, even though they clearly don't. Additionally, building the project for device shows the atlas is loaded immediately at startup.

I can prove the references are to the atlas not the texture (which is the thing we actually care about not loading, because it's 4k-square, and yes we have that much retina-res UI) simply by cloning the atlas, deleting the old one, and confirming that there are now zero references to either the atlas or the texture.

Where are references to UIAtlases held, and how do we clean them up? I'm happy to editor script this if required, but can't understand where the references are from.

We have several buttons which result in launching external iOS dialogs. Most of these call UnityPause(), which in turn results in OnApplicationPause() being called, which then makes a second call into Objective-C functions that aren't safely re-entrant (i.e. displaying a viewcontroller again.)

It's a lot of work to fix up all of these functions (which we didn't write.) Can we safely prevent this duplicate call?


NGUI 3 Support / Fixed-size scrollbar foregrounds (handles)
« on: May 30, 2013, 12:39:23 PM »
Hey Aren,

I want to make a fixed-size (vertical) scrollbar handle, i.e. the scrollbar handle is always a fixed-size sprite (actually 40x40).

The interaction between UIScrollbar and UIDraggablePanel is relatively complex by NGUI standards, so I wanted to ask if there's a simple way to do this, as I couldn't see an easy one just by forcing, say, UIScrollBar.barSize somewhere.

Is there an elegant way to do this? I can make the blob the right size outside of NGUI just by adding a funciton with a lateUpdate to rescale the scrollbar, but then it won't move the full length of the scrollbar (because it stops when the bottom of the scaled widget would have hit.


NGUI 3 Support / HardClipping with Custom UITexture Shader
« on: May 01, 2013, 07:36:28 PM »
Hey Aren,

Quick question before I do some coding: If I have a UITexture with a custom shader in a hardclipped panel, and I implement a hardclipped version of my shader (transform worldpos, call hlsl clip()) and name it correctly should everything "Just work"?

I have a radio-button-controlled group of sprites, and need to highlight the selected one by brightening it. I don't want to create an extra "highlighted state" sprite of each as there are many of them. One way to implement this is a custom shader drawing an additive 20% transparency mask of the selected sprite over the top of itself (i.e. a shader mode of (one, one), and colour-add 20% of the sprite's alpha channel.)

It doesn't matter that this is an extra draw call as long as it happens after the base sprites draw call.

How can I do this? Do I have to duplicate the atlas, then change the shader on the atlas (I assume here that both atlases can reference the same texture.) Or is there another way? I would really rather NOT move to UITextures, where applying custom shader is easy, as there are many of these sprites, and sorting is complex.


PS. I also tried scaling the colour up using a colour tint. But NGUI uses Color32 for vertex colours so this doesn't work out of the box as the sprites are white by default. I switched back to the old codepath (for Unity 3.5.4) using float colours but surprisingly this didn't work.

PPS. Leave aside that this won't highlight things that are already close to 1.0 in RGB space very well. I know...

NGUI 3 Support / Momentary Flicker when Switching Menus
« on: November 30, 2012, 06:41:13 PM »
I'm working on porting "Paint My Cat" to iPhone and iPod touch, and am seeing a momentary flicker (nothing renders in the UI camera) when switching panels (which may have always been there but not noticeable until I ported to slower devices).

My panel switching between menus is accomplished using the world's most naive menu stack system. Like this:
       NGUITools.SetActive(previousPanel.gameObject, true);
            NGUITools.SetActive(currentPanel.gameObject, false);

Is there some other practice that I should be using when switching menus to avoid this?


NGUI 3 Support / Scaling (incorrectly) UICamera to always fill screen
« on: October 29, 2012, 11:22:12 PM »

I'm shipping an iPad game, and all my UI is at 4:3 res (1024x768.)

It also runs fine on my phone, and at some point there will be a proper release on the phone. But that will require more work than just rescaling the UI (there are usability and space tweaks.)

In the meantime, I'd like to be able to just display the UI full-screen, when running on an iPhone rather than iPad. THis will mean the UI is stretched on 4/4S, and very stretched on 5. But I'd just like it to fill the screen and remain functional so I don't have the bars at the side.

Is there a quick way to do this with UICamera before I start writing my own scaling logic/rubbish?


NGUI 3 Support / OnClick() getting called twice on iOS
« on: October 17, 2012, 10:33:00 PM »
I have a strange situation, where one button UICheckbox (and only one, of the many in my scene) seems to get its OnClicked() function called twice after I have exited the screen and gone back in.

This button doesn't do anything interesting, and in fact is not even created procedurally - it just belongs to a panel and was created in the editor. It activates with the panel, and it deactivates afterwards. It doesn't even have any interesting scripts on it - the objects it controls respond to UICkeckbox.onStateChange() delegates.

I've made a DebugOnClick() Monobehavior, and attached it to this button. I can confirm that its Start() function is only ever called once. This implies that there is only one instance of the button. However, after going into and out of the screen (i.e. activating then deactivating the panel), OnClick() is then called twice, with each corresponding onStateChanged() also called twice.

This effectively stops the checkbox working, since clicking it twice is obviously a no-op.

To make debugging this more fun, it happens only on iOS, not on the desktop. I have rewritten the logic for how this checkbox controls other elements in a bunch of ways, using onStateChanged, CheckboxControlledObject, etc, but none of them make any difference since the root cause is OnClick() getting caused twice. (And incidentally, I can hear its clicked sound play twice too.)

So, has anyone seen anything similar to this? The call stack for both OnClick() calls is identical, so I'd like to know where the UICamera builds its list of objects to send messages so I can instrument when this checkbox gets added and removed.

Clicked button: "UI Root (2D)/UI Camera/AnchorCenter/PaintingPanel/LowerRightButtons/MagnifierButton"
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
UICamera:Notify(GameObject, String, Object)
UICamera:ProcessTouch(Boolean, Boolean)



NGUI 3 Support / Drawing subregions of a sprite.
« on: October 14, 2012, 08:10:01 PM »
Is there a way to tell a sprite to draw a dynamically selected subregion of itself, e.g. for revealing a sprite in a top-down manner?

For example, suppose that I have a 64x64 sprite, and in frame n, I want to draw a 64xn subregion of the sprite, with both vertex positions and UVs forming a rectange from (0, 0) to (64, n) , so that the sprite reveals from the top down? This obviously can't be done with just a scale because I want the same screen pixel of the sprite to always correspond to the same texel.

Is there an easy way to do this in NGUI?


NGUI 3 Support / Resetting the state of a group of radio buttons
« on: October 13, 2012, 03:18:39 PM »
What is the correct way to reset the state of a group of radio buttons such that you say "this button is the active one, and all the others should now to inactive."

I also have tweens in/out (driven by OnActivate()) on the buttons, and would like them to be called correctly.

I tried iterating over the n checkboxes and calling OnActivate(true) on the one to be checked, and OnActivate(false) on all others. But this didn't seem to work correctly, in that the one I had then activated didn't then didn't reset when I clicked on a different box.

Is there a different way to handle this? I searched but couldn't find a good answer.


I have two panels, A and B, and I'm switching between them using a simple NGUITools.SetActive() call, like here:

This seems to activate/deactivate the two screens (panels) correctly, but doesn't stop them rendering. So as soon as I switch menu the first time, I have both visible, but only one selectable at a time.

What obvious thing am I doing wrong?

Pages: [1]