public override void OnInspectorGUI() { Handle02 targetWithType = (Handle02)target ; m_Switch = (HandleDemonstration)EditorGUILayout.EnumPopup( "Switch" , m_Switch ) ; targetWithType.m_StartPoint = (Transform) EditorGUILayout.ObjectField( "StartPoint" , targetWithType.m_StartPoint , typeof( Transform ) , true ) ; targetWithType.m_EndPoint = (Transform) EditorGUILayout.ObjectField( "EndPoint" ,targetWithType.m_EndPoint , typeof( Transform ) , true ) ; targetWithType.m_ControlPoint0 = (Transform) EditorGUILayout.ObjectField( "ControlPoint0" ,targetWithType.m_ControlPoint0 , typeof( Transform ) , true ) ; targetWithType.m_ControlPoint1 = (Transform) EditorGUILayout.ObjectField( "ControlPoint1" ,targetWithType.m_ControlPoint1 , typeof( Transform ) , true ) ; m_AATexture = (Texture2D) EditorGUILayout.ObjectField( "AATexture" , m_AATexture , typeof( Texture2D ) , false ) ; m_ScaleSize = EditorGUILayout.FloatField( "ScaleSize" , m_ScaleSize ) ; m_Color1 = EditorGUILayout.ColorField( "Color1" , m_Color1 ) ; m_Color2 = EditorGUILayout.ColorField( "Color" , m_Color2 ) ; if (GUI.changed) { EditorUtility.SetDirty (targetWithType); } }
// change layout of Inspector public override void OnInspectorGUI() { // target is the class of ExecuteInEditMode01 Handle01 targetWithType = (Handle01)target ; m_Switch = (HandleDemonstration) EditorGUILayout.EnumPopup( "Choose Enum" , m_Switch ) ; m_HandlesColor = EditorGUILayout.ColorField( "Handles.color" , m_HandlesColor ) ; switch( m_Switch ) { case HandleDemonstration.FreeMoveHandle : m_RectangleSize = EditorGUILayout.FloatField( "RectangleSize" , m_RectangleSize ) ; break; case HandleDemonstration.ScaleSlider : EditorGUILayout.FloatField( "ScaleSize" , m_ScaleSize ) ; break ; case HandleDemonstration.ScaleHandle : case HandleDemonstration.ArrowCap : case HandleDemonstration.CircleCap : case HandleDemonstration.ConeCap : case HandleDemonstration.CubeCap : case HandleDemonstration.CylinderCap : case HandleDemonstration.SphereCap : case HandleDemonstration.DotCap : case HandleDemonstration.DrawSolidArc : case HandleDemonstration.DrawWireArc : case HandleDemonstration.DrawSolidDisc : case HandleDemonstration.DrawWireDisc : m_ScaleSize = EditorGUILayout.FloatField( "ScaleSize" , m_ScaleSize ) ; break; case HandleDemonstration.Disc : m_DiscCutOff = EditorGUILayout.Toggle( "DiscCutOff" , m_DiscCutOff ) ; break ; case HandleDemonstration.BeginGUI : m_BeginGUIAtScene = EditorGUILayout.RectField( "BeginGUIAtScene" , m_BeginGUIAtScene ) ; m_BackgroundTexture = (Texture2D) EditorGUILayout.ObjectField( "Background Texture " , m_BackgroundTexture , typeof( Texture2D ) , false ) ; m_Style1.fontSize = EditorGUILayout.IntField( "FontSize" , m_Style1.fontSize ) ; m_Style1.normal.textColor = m_HandlesColor ; m_Style1.normal.background = m_BackgroundTexture ; break; case HandleDemonstration.Label : m_LabelString = EditorGUILayout.TextField( "LabelString" , m_LabelString ) ; m_Style1.fontSize = EditorGUILayout.IntField( "FontSize" , m_Style1.fontSize ) ; m_Style1.normal.textColor = m_HandlesColor ; break ; case HandleDemonstration.ClearCamera : m_BeginGUIAtScene = EditorGUILayout.RectField( "BeginGUIAtScene" , m_BeginGUIAtScene ) ; break ; } if( GUI.changed ) { EditorUtility.SetDirty( targetWithType ); } }