Author Topic: MiniMap circle mask  (Read 4794 times)

Darkness

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 90
    • View Profile
MiniMap circle mask
« on: October 17, 2017, 04:54:28 PM »
So, I'm trying to get my minimap working and I'm trying to figure out how to use a circle mask.  What is the best way to do this without having to write a shader (which I don't think should be needed as it seems like a simple thing for a GUI to do naturally)?  I'm currently using UITexture so that the renderTexture can be used as the sprite, but I don't see anywhere for this to happen.  Is there a better way for this to work?  Any information that can be given would be greatly appreciated.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: MiniMap circle mask
« Reply #1 on: October 19, 2017, 02:39:28 AM »
UIPanel can accept a clipping mask. Just specify a circular mask there, and it will clip everything below it. You don't need a shader for this, assuming you're going to be using the default NGUI shaders for the sprites within.

Darkness

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 90
    • View Profile
Re: MiniMap circle mask
« Reply #2 on: October 19, 2017, 02:55:50 PM »
Thanks for the info, AM.  I do have a problem with it, though.  I setup the panel with the mask and it works...only if I manually changed the drop down to "None", then back to "Texture Mask".  Do you know why it wouldn't just start working upon startup?  I tried doing myMapPanel.Refresh() and myMapPanel.Update() and neither would force the panel to mask properly.  It only works if I manually do it while the editor is running.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: MiniMap circle mask
« Reply #3 on: November 06, 2017, 07:01:27 AM »
I gave this a brief test -- new scene, ALT+SHIFT+S, right click to make a new panel, changed it to use a texture mask for clipping and dragged the sprite underneath it. I then saved the scene, went to another scene and returned to the test one -- still clipped fine. Can you explain what you're doing differently?

Darkness

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 90
    • View Profile
Re: MiniMap circle mask
« Reply #4 on: November 29, 2017, 06:28:05 PM »
I'm not doing anything differently.  It's like this:

[Parent] MiniMap Panel
[Child] ->UI Texture (used for minimap)

MiniMap Panel is set to Texture Mask.
The UI Texture is given a Render Texture and uses Unlit/Transparent Masked shader.

Nothing else to say about it since it's pretty simple.  Looks fine in the editor, but when I actually run the project, it goes back to being unclipped and I have to manually change the clipping.  Doing it via software doesn't do anything.  Maybe it has something to do with it being a Render Texture?  Either way, I'm not sure what's going on, but not even changing it via software will work.