[Unity插件]Outline3D2D物体描边插件的使用说明

来源:互联网 发布:深圳市行知职校 校长 编辑:程序博客网 时间:2024/05/22 12:36


Outline Effect



Carmera物体的 Outline Effect 组件,的Line Color 0-2 ,都是可以控制 物体描边的。

通过修改 如下图所示的几个 选项,就可以达到不同颜色 的Outline 描边的效果。



------------------------------------------如果想要添加更多的颜色,就得找到 更多 的 Color 代码。 (最后发现实现不了更多的 lineColor)

如果想要添加更多的颜色,就得找到 更多 的 Color 代码。 

打开OutlineEffect.cs 组件,在VS 中 搜索关键词 lineColor,就可以找到



添加3个 颜色Color,如下图所示



添加3个Material 材质,如下图所示


 

返回值为Material的GetMaterialFromID函数的 对象 如下图所示



在接下来的有outline1Material的地方添加颜色4,5,6对应的代码,如下图所示




这里的outline1Material = CreateMaterial(new Color(1, 0, 0, 0));

的Color 的代码,才是控制 初始颜色的 材质的 主要的代码。(通过搜索引擎 ,Unity API,color。详见 相关文章2)


然后发现,根本添加不了多的组件,也就是说,红色方框的 内容 可以使用,改变颜色,也会改变相应的 Outline Effect效果,

绿色方框 内的颜色则改变不了。


------------------------------------------闪烁描边效果的使用

闪烁描边效果的使用


对 使用了黄色 描边的物体,都会进行闪烁,绿色物体则不进行闪烁。


把上图所示的MainCamera物体的OutlineAnimation.cs组件打开,改变第21行的

            Color c = GetComponent<OutlineEffect>().lineColor0;

的lineColor0改为(lineColor1或者lineColor2)都是可以进行闪烁。

如果要实现多个颜色lineColor1或lineColor2同时进行闪烁,则需要把Update函数内的代码,改写成一个函数。

用函数来 控制变量。




------------------------------------------多个相同颜色 的物体 同时闪烁

如果想让多个 相同颜色 的物体 闪烁,OutlineAnimation.cs 就得如下图所示



using System.Collections;using System.Collections.Generic;using UnityEngine;using cakeslice;namespace cakeslice{    public class OutlineAnimation : MonoBehaviour    {        bool pingPong = false;        // Use this for initialization        void Start()        {        }        // Update is called once per frame        void Update()        {            Color c = GetComponent<OutlineEffect>().lineColor0;            Color c1 = GetComponent<OutlineEffect>().lineColor1;//            if (pingPong)            {                c.a += Time.deltaTime;                c1.a += Time.deltaTime;//                if (c.a >= 1)                    pingPong = false;            }            else            {                c.a -= Time.deltaTime;                c1.a -= Time.deltaTime;//                if (c.a <= 0)                    pingPong = true;            }            c.a = Mathf.Clamp01(c.a);            GetComponent<OutlineEffect>().lineColor0 = c;            c1.a = Mathf.Clamp01(c1.a);//            GetComponent<OutlineEffect>().lineColor1 = c1;//            GetComponent<OutlineEffect>().UpdateMaterialsPublicProperties();                    }    }}



------------------------------------------




相关文章:

1.[Unity插件][Shader资源]Outline2D3D物体描边插件2D图片模糊灰度变色水滴特效插件

2.

Color

3.

4.