创作不易 如果对你有帮助 麻烦点个赞支持一下效果预览
代码部分
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeControllerScript : MonoBehaviour
{
public Renderer renderer;
[Header("CubeLine")]
public Color32 LineColor;
public Color32 CubeColor;
[Range(0, 0.5f)] public float LineWeight;
[Header("Font")]
public Color FontColor;
[Range(0, 72f)] public float FontSize;
[Header("Other")]
[Range(0, 1000)] public int Count;
private MaterialPropertyBlock propertyBlock;
private void Start()
{
propertyBlock = new MaterialPropertyBlock();
renderer = GetComponent<Renderer>();
}
private void Update()
{
// 更新材质的颜色属性
propertyBlock.SetColor("LineColor", LineColor);
propertyBlock.SetColor("CubeColor", CubeColor);
propertyBlock.SetFloat("LineWeight", LineWeight);
// 应用新的属性值到渲染器上的材质
renderer.SetPropertyBlock(propertyBlock);
}
}
注意事项
此处"LineColor"为Shader文件中的命名
[2048]Unity怎么给Cube游戏对象添加外边框线(描边)https://blog.csdn.net/Kuromi__/article/details/136736055
参考博主https://blog.csdn.net/baidu_35080512/article/details/125540228