在unity中实现简单的程序纹理 【Unity Shader 入门精要10.3.1】

本篇博客介绍如何在Unity中利用Shader实现程序纹理,通过学习Unity Shader入门精要10.3.1章节,掌握SetProperty插件的使用,实现更灵活的纹理效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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



//在unity中实现简单的程序纹理   10.3.1


//在编辑模式执行
[ExecuteInEditMode]
public class ProceduralTextureGeneration : MonoBehaviour {
    //声明一个材质,这个材质将使用该脚本中生成的程序纹理
	public Material material = null;

    //声明程序纹理将使用的各种参数
    //使用插件SetProperty将参数显示在面板上,这使得当修改了材质属性时,可执行_UpdateMaterial函数来使用新的属性重新生成程序纹理
	#region Material properties
	[SerializeField, SetProperty("textureWidth")]
    //材质纹理宽度
	private int m_textureWidth = 512;
	public int textureWidth {
		get {
			return m_textureWidth;
		}
		set {
			m_textureWidth = value;
			_UpdateMaterial();
		}
	}
    //材质纹理背景颜色
	[SerializeField, SetProperty("backgroundColor")]
	private Color m_backgroundColor = Color.white;
	public Color backgroundColor {
		get {
			return m_backgroundColor;
		}
		set {
			m_backgroundColor = value;
			_UpdateMaterial();
		}
	}
    //材质纹理圆形颜色
	[SerializeField, SetProperty("circleColor")]
	private Color m_circleColor = Color.yell
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值