Unity3d show round or irregular backgrounds

Source: Internet
Author: User

Displays a rounded background in the unity3d. There are two ways, one is to display on the GUI, which is usually used on the UI. The other is shown by the 3D plane, which is used in the game scene, such as a small map of the game.

1. GUI Display


Add a background image, add a picture, respectively, is a transparent background, black round and black five corners, PNG pictures.



Add a panel, and then add an image under the panel



Add the picture background to the image



Add a mask component to a panel



Add the circle to the panel



This time, you can see a circular background map.



If you add a five-point shape to a panel, you see a five-angle background.



2. Plane method

This method is suitable for making small maps.


First add a shader



Change a name.



Double-click to edit content later

Shader "Custom/mask" {Properties{_maintex ("Main Texture", 2D) = "White" {}_mask ("Mask Texture", 2D) = "White" {}}subshader {Lighting onzwrite offblend srcalpha oneminussrcalpha Pass {settexture [_mask] {combine texture}settexture [_maintex] {Co Mbine texture,previous}}}}

In PS inside make a black bottom, Bai. Save As TGA format



Locate the imported TGA file



Reset properties as follows


Add a plane to the scene and drag the background onto the plane



Select the resulting material



Change the shader property to Custom/mask



Set the mask texture property to mask, and this time in the editor it becomes round.



The camera's clear flages property needs to be set to depth only



Run the preview and you'll see the round background. When used, you need a dual camera, a display background, a display content.


Unity3d show round or irregular backgrounds

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.