博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Odin Inspector 系列教程 --- On Value Changed Attribute
阅读量:4147 次
发布时间:2019-05-25

本文共 939 字,大约阅读时间需要 3 分钟。

On Value Changed Attribute:处理属性和字段,并且只要通过检查器更改了值,就会调用指定的函数。

7643202-0b7b0d4bb69ee8b6.gif
using Sirenix.OdinInspector;using System.Collections;using System.Collections.Generic;using UnityEngine;public class OnValueChangedAttributeExample : MonoBehaviour{    [ShowInInspector]    [EnumPaging, OnValueChanged("SetCurrentTool")]    [InfoBox("更改此属性将更改Unity编辑器中当前选择的工具.")]    private UnityEditor.Tool sceneTool;    private void SetCurrentTool()    {        UnityEditor.Tools.current = this.sceneTool;        Debug.Log($"更改为:{UnityEditor.Tools.current}");    }    [OnValueChanged("CreateMaterial")]    public Shader Shader;    [ReadOnly, InlineEditor(InlineEditorModes.LargePreview)]    public Material Material;    private void CreateMaterial()    {        if (this.Material != null)        {            Material.DestroyImmediate(this.Material);        }        if (this.Shader != null)        {            this.Material = new Material(this.Shader);        }    }}

更多教程内容详见:

转载地址:http://sijti.baihongyu.com/

你可能感兴趣的文章
Java通用字符处理类
查看>>
文件上传时生成“日期+随机数”式文件名前缀的Java代码
查看>>
Java代码检查工具Checkstyle常见输出结果
查看>>
北京十大情人分手圣地
查看>>
Android自动关机代码
查看>>
Android中启动其他Activity并返回结果
查看>>
2009年33所高校被暂停或被限制招生
查看>>
GlassFish 部署及应用入门
查看>>
X-code7 beta error: warning: Is a directory
查看>>
Error: An App ID with identifier "*****" is not avaliable. Please enter a different string.
查看>>
3.5 YOLO9000: Better,Faster,Stronger(YOLO9000:更好,更快,更强)
查看>>
iOS菜鸟学习--如何避免两个按钮同时响应
查看>>
iOS菜鸟学习—— NSSortDescriptor的使用
查看>>
CORBA links
查看>>
读后感:>
查看>>
如何使用BBC英语学习频道
查看>>
初识xsd
查看>>
java 设计模式-职责型模式
查看>>
构造型模式
查看>>
svn out of date 无法更新到最新版本
查看>>