For beginners in Unity, how to quickly use the plugin to set the highlight state

Preface: I believe that many friends will need to use the effect of object highlighting in the process of developing games , as shown in the figure.

 In the initial stage, we don't need to write complex shaders by ourselves, but quickly use plug-ins to solve the needs of this function. The following is a free highlighting plugin we will use in this article: Quick Outline Quick Outline | Particles/Effects | Unity Asset Store

1. Import the Quick Outline plug-in in the resource mall

 2. Mount the Outline script in the resource pack to the object that needs to be highlighted

 

3. When running at this time, the object will always be highlighted, which is not the effect we want. Therefore, we need to add a script to control it.

public class HighLight : MonoBehaviour
{
    public Outline outline;  

    void OnMouseEnter()  //鼠标进入 
    {
        outline.enabled = true;
    }

    void OnMouseExit()  //鼠标退出
    {
        outline.enabled = false;
    }
}

Mount the newly written HighLight script to the highlighted object, and uncheck the Outline script . as the picture shows:

 At this time, run it again, and the effect at the beginning of the article will appear, that is: only when the user mouse enters the object, the highlighted stroke effect will be displayed, and it will not be displayed when the user exits.

Guess you like

Origin blog.csdn.net/m0_64688993/article/details/131380114