usingSystem.Collections;usingSystem.Collections.Generic;usingUnityengine;usingUnityeditor;usingSystem; [Executeineditmode] [Customeditor (typeof(TESTXX))] Public classTestxxeditor:editor {[Serializefield] Public floatSlider_value =0.3f; Public BOOLCHK =false; Serializedproperty check; //Use this for initialization voidStart () {}voidonenable () {Check= Serializedobject.findproperty ("x"); Debug.Log ("============"+check.floatvalue); } //Update is called once per frame voidUpdate () {} Public Override voidOninspectorgui () {if(Guilayout.button ("Hello")) { //testxx otx = (testxx) target;//otx.x = 5.93f;//Otx.check = false;Debug.Log ("Hello------------"); } slider_value= Editorguilayout.slider (Slider_value,0,1.0f); CHK= Guilayout.toggle (CHK,NewGuicontent ("chk")); Editorguilayout.propertyfield (check); Serializedobject.applymodifiedproperties (); }}
usingSystem.Collections;usingSystem.Collections.Generic;usingUnityeditor;usingUnityengine;//[Executeineditmode] Public classTestxx:monobehaviour {[Range (1,Ten)] Public floatx =0; Public stringText ="Hello"; Public BOOLCheck =false; Public BOOL[] Chks =New BOOL[Ten]; //Use this for initialization voidStart () {}//Update is called once per frame voidUpdate () {if(check) {Debug.Log ("=================="+x); } }}
Hang the Testxx.cs on an object and click the go to see the relevant UI customized on Inspector
UNITY Manual Custom Inspector