yufenghou
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;


public class Test : MonoBehaviour {


	[SerializeField][HideInInspector]
	private int _width;


	public int width
	{
		get
		{
			return _width;
		}
		set
		{
			_width=value;	
			Debug.Log("set:"+value);
		}
	}

}

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


[CustomEditor(typeof(Test))]
public class TestInspector : Editor {

	Test model;
	public override void OnInspectorGUI()
	{
		base.DrawDefaultInspector();

		//target是监视的物体对象,相当于获取target上面的Test脚本
		model = target as Test;
		int width = EditorGUILayout.IntField("Width",model.width);
		if(model.width!=width)
		{
			model.width = width;
		}
			
	}

}


分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2021-11-29
猜你喜欢
  • 2021-04-29
  • 2022-12-23
  • 2021-11-07
  • 2021-11-10
  • 2022-12-23
相关资源
相似解决方案