Search Unity

How do I cut a shape out from a sprite

Discussion in 'Getting Started' started by DoctorFinkle, Jan 28, 2019.

  1. DoctorFinkle

    DoctorFinkle

    Joined:
    Jun 2, 2018
    Posts:
    5
    I have a circle sprite and I want to make a ring. How do I cut out a circle from it?
     
  2. DoctorFinkle

    DoctorFinkle

    Joined:
    Jun 2, 2018
    Posts:
    5
    Does this require masking?
     
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Yes, the short, Getting-Started-level answer is, "you don't." Just make another, ring-shaped sprite.
     
    Kiwasi likes this.
  4. DerrickMoore

    DerrickMoore

    Joined:
    Feb 4, 2018
    Posts:
    246
    ok... use two cameras... one camera has a "gimbol" or a "traveling matte" on it.. that's just a circle cut out (should work with an ortho camera view), call that HoleCamera.. give it a deapth of 99, since you want it drawn on top... have it, do nothing with the background.. "don't clear" I think..

    ok, second camera, just duplicate the first, without the Traveling Matte (https://encyclopedia2.thefreedictionary.com/Traveling-Matte+Method) call this camera RegularCamera and give it a depth of 98, so it's lower than HoleCamera…

    wait.. now make the matte visible only to HoleCamera via Layers... now HoleCamera can see a black field, with just a small circle with a view... If I make that black field a "zero color" like a "greenscreen" I can have Regular Camera imagry in the back, with HoleCamera imagry imposed on top.. and I do not draw the "zero color"

    now there's an easy way to do that "not draw the Zero Colour".. I'm just not sure how to do that in Unit...

    maybe using a "portal" would be easier

    wait, Even better.. use Render Texture into a Rawimage onto a circle gameobject placed onto the sprite...
     
    Last edited: Jan 30, 2019
  5. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Several options.
    • For really simple tasks, just create the sprite with a transparent hole in your art software
    • For medium complexity cutouts use a Sprite Mask
    • For complex systems, you are probably going to want to write your own shader. Its a complex topic, but the new Shader Graph system dramatically simplifies the process.