Highlighting物体边缘发光插件的基本用法

Highlighting Effect脚本拖拽到Main camera上面

Hightlighting Controlller脚本拖拽到要显示发光的物体上面

Hightlighting Controlller内的内容根据需求写,

例1:鼠标进入物体发光,离开光熄灭

using UnityEngine;
using System.Collections;

public class HighlightingController : MonoBehaviour
{
	protected HighlightableObject ho;
	
	void Awake()
	{
		ho = gameObject.AddComponent<HighlightableObject>();
	}
	
	void Update()
	{
		AfterUpdate();
	}
    private void OnMouseEnter()
    {
        ho.ConstantOn(Color.green);
    }
    private void OnMouseExit()
    {
        ho.ConstantOffImmediate();
    }

    protected virtual void AfterUpdate() {}
}

例2:生成物体发光,3秒后消失

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class bringHighligting : MonoBehaviour {

    protected HighlightableObject ho;

    void Awake()
    {
        ho = gameObject.AddComponent<HighlightableObject>();
    }

    void Start () {
        ho.ConstantOn(Color.red);
        StartCoroutine(Timer());
	}
	
	// Update is called once per frame
	void Update () {
        AfterUpdate();
    }

    protected virtual void AfterUpdate() { }
    IEnumerator Timer()
    {
        yield return new WaitForSeconds(3f);
        ho.ConstantOffImmediate();
    }
}

猜你喜欢

转载自blog.csdn.net/qq_41579634/article/details/83859889