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

Pages: 1 ... 3 4 [5] 6 7 8
NGUI 3 Support / Re: Any alternatives to UIPanels for hard edge clipping?
« on: October 11, 2014, 05:31:56 AM »
Yep, works great!

NGUI 3 Support / Re: Any alternatives to UIPanels for hard edge clipping?
« on: October 11, 2014, 05:03:25 AM »
Oh, that's a great idea. Let's say I have a separate UIPanel with a component that can set it's dimensions and position, with a singleton to access it, and a child ripple sprite that can tween through the touch animation. Any touchable widget can call the singleton and invoke a method (using itself as an argument) on touch, which will reposition the UIPanel clip area to dimensions of a widget arriving in the argument and start the ripple animation in the clicked point of the screen. Nice!

NGUI 3 Support / Re: Simple anchor setup question
« on: October 11, 2014, 04:58:28 AM »
Eh? The relative value is it. 0 means left, 0.5 means center, 1 means right. Check the documentation for the UIRect.
Oh, thanks, that's a relief, I assumed both were pixel offsets than had nothing to do with setting the point of origin. :)

NGUI 3 Support / Any alternatives to UIPanels for hard edge clipping?
« on: October 11, 2014, 04:20:08 AM »
I'm implementing a reusable UI based on Android interface guidelines. Many animated elements from the guidelines can easily be implemented using simple layered sprites. For example, here are standard switches using three simple NGUI sprites each:

With other elements, here is a tiny little problem, though. That problem is the extreme use of clipped effects on rectangular clickable elements. Check the following sample animations from the guidelines:

Every touch creates an ripple that must be clipped within the touched element. That's where things get tricky. You can imitate it pretty easily using UIPanel, of course:

Except you definitely do not want UIPanels within the hierarchy of every single button, tab, field and card, because you do not want to isolate parts of your widgets into an entirely separate part of depth hierarchy and because you do not want to clutter your panel list with those tiny clip areas. So, is there some lightweight alternative to UIPanel that can only do clipping (not even soft edge, extremely crude rectangular edge clipping, for example depth based, will suffice too - no need for texture-defined masking, no need for circular clipping, nothing like that) without all other rich functionality and hierarchy fragmentation UIPanels bring with them?

NGUI 3 Support / Re: Simple anchor setup question
« on: October 11, 2014, 03:57:20 AM »
Yes, I know about widget.*anchor.Set - but there is no overload that allows you to set up snapping to the left/right/top/bottom edge, only relative offset, absolute offset and optional transform you have to come up with yourself, supposedly. How can I get the Transform reference to the center of the left edge of a widget I'm anchoring to, for example? Without calculating that position from scratch, that is - it's possible to do so, but I suspect NGUI already calculates those points to present them in the custom inspector of the anchors.

NGUI 3 Support / Re: Texture Memory & Labels - Best Practices?
« on: October 10, 2014, 02:12:04 AM »
If you are using Unity Pro, the detailed data can be found in the Profiler window.

NGUI 3 Support / Re: How to make letters outline smooth ?
« on: October 10, 2014, 02:09:56 AM »
As I've said, it's impossible to do that with a true type label, there is no data in the rasterized text to produce a proper outline. Duplicating and shifting the silhouette is the best that can be done.

Another alternative that won't require a bitmap is to use mesh-based text. There are plenty of text-to-geometry assets on the Asset Store, and some support enormously complex outlines. They will work with a .ttf source and won't require bitmap preparation for each character. Although I sure hope you only need that effect for some rare hero label - a solution like that is obviously completely unfit for dozens of labels per frame or dynamically changing content.

NGUI 3 Support / Re: How to make letters outline smooth ?
« on: October 09, 2014, 06:17:23 AM »
If you need a complex high quality outline, I'd recommend to use a bitmap font where a designer would prepare every glyph with the effect you want. It's impossible to create smooth high-radius outline directly with an arbitrary label font. NGUI outlines are essentially four shadows, i.e. four absolutely identical silhouettes shifted into four directions - you can't do anything better dynamically.

NGUI 3 Support / Simple anchor setup question
« on: October 09, 2014, 05:39:02 AM »
I was not able to figure it out from the documentation so I apologize if it is obvious. The question is: how can I (through code) set the reference points of Unified anchoring of a widget to Top/Bottom/Left/Right enum values that NGUI inspector UI always offers you to use? I have not found any argument like that in the SetAnchor method or among the properties of individual anchors, which leaves me reliant on rather ugly hack where I match the pixel dimensions and position of an anchored widget to those of it's parent and hope that NGUI auto-selects the appropriate reference mode on each of the four anchor points. It usually does, because mode I want has the closest relative offset (zero), but I'd rather avoid doing that.

I understand that those handy enums and Unified anchoring mode on the whole are probably just editor-side wrapping of underlying auto-generated Transforms and underlying Advanced anchoring mode, and I see the methods allowing you to set reference Transforms for anchors, but I'm not seeing any way to fetch those points in the first place. I can calculate the 4 corner points and 4 side midpoints myself, of course, and create my own transforms there, but that would be very dirty and I'd rather prefer to find a way to get a reference to existing ones.

Components placed on UI objects with colliders enjoy extremely useful messages OnHover and OnPress that can be used to call void methods with isOver and isDown bool arguments. This allows me to easily hook complex animated behavior outside of UIButton scope to buttons, for example.

Unfortunately there is an inconvenience - I'm creating prefabbed UI elements with wrapper components (like ready for use buttons with labels), and I'd prefer the wrapper component to be alone on a parent object, with the label, sprite, collider and other stuff being in the hierarchy under it. Naturally, those neat messages stop arriving to my component when there is no collider on it. As a workaround, I'm trying out subscribing that component on a parent GameObject to the UIButton events, but I'm not sure if the same functionality is supported through that. I'm using the following simple code:

  1. referenceButton.onClick.Add (new EventDelegate (this, "OnPress"));

But as far as I understand, the button can't send that event with bool arguments describing whether a press has started or ended; and there is no hover event at all. Is there any way to get four state input response (hover entered area, hover left the area, click started, click ended) on a remote object or should I abandon use of events altogether and use a collider on a parent to intercept all those messages directly?

Very obvious workaround is to create a component placed onto the child GameObject with UISprite/Collider that will do absolutely nothing but catch OnHover/OnPress messages and relay them to the reference of my wrapper component - but it would be very nice if I could avoid cluttering the project with classes of that sort.


Edit: Oh, I see I have overlooked UIEventListener class.
I'm not sure I follow how it works though. The example contained in the description of that class is not working:

  1. UIEventListener.Get(gameObject).onClick += MyClickFunction;
Error: Operator `+=' cannot be applied to operands of type `UIEventListener.VoidDelegate' and `method group'


Edit 2: I think I got it working, looks like every single method called through needs a GameObject argument in addition to standard arguments like bools described in the event tutorial.
Could it be down to the fact that I'm subscribing on creation of the button in the editor? Maybe it only works when I subscribe ingame?


Edit 3: Yeah that was it, any and all subscriptions should be performed when the game is running.

NGUI 3 Support / Re: Sprite anchor problem on multiple uiroots
« on: October 07, 2014, 06:42:29 AM »
I assume you are separating parts of UI like windows into separate scenes and separate UIRoots? It's not really necessary, windows can be simply separated using UIPanels, and generally it's worth keeping UI scene independent. I have some situations where I need to pick up some part of UI from a scene, though, and in that case I simply keep track of what I'm adding and parent the found panel to already existing singular UIRoot.

NGUI 3 Support / Re: How to make object's [On Selected] animation?
« on: October 02, 2014, 06:34:56 AM »
It completely depends on your art direction. For simple outline, you can just create another sprite underneath the character portrait, with the same shape (sliced rectangle, circle or whatever you have in the main portrait sprite), enlarge it until you're satisfied with the outline, then set transform scale to 0 and tween it to whenever you want the outline to appear. Or you can simply tween it's alpha without hiding the outline through transform scale.

NGUI 3 Documentation / Re: UIRoot
« on: September 22, 2014, 11:13:49 AM »
So, if I understand correctly, there is no way to directly influence the resolution of pixel area through UIRoot when you are using a 3D camera, with scaling options having no effect unless you are using a 2D camera?

It might be a good idea to communicate that in the UIRoot inspector hints then :)

NGUI 3 Documentation / Re: UIRoot
« on: September 22, 2014, 08:18:01 AM »
I'm a bit confused with the new UI root scaling. I am using a 3D UI in Constrained mode with height set to 1080 and fit option enabled for it.

Despite that setting, I'm actually getting 2629x1478 pixel area (measured by anchoring a sprite to UIRoot object dimensions). Experimenting with UIRoot further, I found it impossible to actually change that 1478px height with any UIRoot configuration - the only thing that changes is UIRoot transform scale and (if I switch the screen from 16:9 to free aspect and and drag the proportions around) pixel area width, but never the height, no matter what I use (Constrained or Flexible, fitted or not, any resolution in any field). What am I missing?

Edit: Aha, I see it depends on the 3D camera Z distance from the origin. That distance is not directly translated to pixel area height, though: you get 1478 vertical pixels from the camera situated at -1536, and that proportion (1.03924221922) is not really ringing any bells to me. I have just checked the default 3D UI prefab, and the camera Z offset is set to 700 there, which translates to pixel area height of 810, which is again completely incorrect (for default UIRoot fit height setting of 720 pixels). The size also depends on FOV of the camera. I'd expect one of those parameters to be directly controlled by UIRoot depending on selected resolution, but nothing actually happens with them no matter what you input into UIRoot.

What's going wrong here?

Okay. How can I disable pre-modulation of the RGB by the alpha channel in the atlas maker? As far as I see, there is no such option.
Or it's not influencing the quality of sprites even if I'm using a Transparent Colored shader, which means I only have to directly edit the material settings of the atlas without touching atlas maker at all (which assigns PMA by default)?

Aside from that, the question of getting semi-transparent sprite colors correctly rendered into RGB of a render texture (without mixing with clear color, see the last edits and a screenshot above) still stands - how can I achieve that?

Pages: 1 ... 3 4 [5] 6 7 8