Author Topic: Mask a NGUI Texture?  (Read 8135 times)

eco_bach

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Mask a NGUI Texture?
« on: January 29, 2017, 06:55:05 PM »
Hi
I have a Texture 2D inside a NGUI panel object that I need to mask. And then dynamically move so that more of the texture is revealed.

I've never attempted to mask an NGUI texture before.
Can anyone suggest how this is done?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Mask a NGUI Texture?
« Reply #1 on: January 30, 2017, 07:24:59 AM »
NGUI's panels can use a texture mask for clipping. When enabled, NGUI uses the "(TextureClip)" suffix shaders -- code is within and is very simple. Based on your description I don't think you even have to modify it. Just adjust the size of the panel or the texture within as needed.

eco_bach

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: Mask a NGUI Texture?
« Reply #2 on: January 30, 2017, 11:55:50 AM »
Thanks. Almost there but still doing something wrong.

First let me confirm what I am trying to do.
Simply mask a NGUI Texture nested in a NGUI panel.

I've done the following
1-Selected the NGUI Panel and in the UI Panel Script set the type to Texture Mask.
2-Created a simple bitmap that I want to use as a mask. Imported this and changed the type to Sprite(2D and UI)
3-Dragged this new texture to the Select swatch associated with my Panel Texture Mask
4- Changed the size to the bitmaps original pixel dimensions

Now I assume that changing the offset values of this Texture mask should allow me to properly mask or reveal the nested NGUI texture
But whats seems to happen is all or nothing. The moment even part of the Texture Mask is 'on top of' the nested NGUi Texture it is entirely revealed.

I tried changing the shader for the nested NGUI Texture from Hidden/Unlit/Transparent Colored to Hidden/Unlit/Transparent Colored (texture Clip)

Any help appreciated as this is the first time I have tried masking in NGUI and am falling behind a project launch.

eco_bach

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: Mask a NGUI Texture?
« Reply #3 on: January 30, 2017, 12:01:22 PM »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Mask a NGUI Texture?
« Reply #4 on: February 04, 2017, 03:37:18 AM »
Not sure, I can't access that link.

NGUI can't nest clipped and texture masked panels. You need to choose one or the other. Texture clipping is exclusive of all other forms of clipping. Rect clipping can be nested, texture clipping can't.