1. Add the input box and label Levelscript:
using Unityengine; using System.Collections; Public class Levelscript:monobehaviour { publicint experience; Public int level { getreturn; }}}
Levelscripteditor
Note: in
Oninspectorgui
The following code is added to the event to append the default properties:
DrawDefaultInspector();
sing unityengine;usingSystem.Collections;usingUnityeditor; [Customeditor (typeof(Levelscript))] Public classLevelscripteditor:editor { Public Override voidOninspectorgui () {levelscript mytarget=(levelscript) target; Mytarget.experience= Editorguilayout.intfield ("Experience", mytarget.experience); Editorguilayout.labelfield (" Level", myTarget.Level.ToString ()); }}
Effect:
2. Add button Objectbuilderscript
using Unityengine; using System.Collections; Public class Objectbuilderscript:monobehaviour { public gameobject obj; Public Vector3 spawnpoint; Public void Buildobject () { instantiate (obj, Spawnpoint, quaternion.identity); }}
Objectbuildereditor
usingUnityengine;usingSystem.Collections;usingUnityeditor; [Customeditor (typeof(Objectbuilderscript))] Public classobjectbuildereditor:editor{ Public Override voidOninspectorgui () {drawdefaultinspector (); Objectbuilderscript MyScript=(objectbuilderscript) target; if(Guilayout.button ("Build Object") ) {myscript.buildobject (); } }}
Unity Rotten Pen 1-Custom Inspector Properties Window node entry