public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.Space(); EditorGUILayout.LabelField("VRSF Parameters", EditorStyles.boldLabel); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); Undo.RecordObject(_scrollbar.gameObject, "Add BoxCollider"); if (_scrollbar.gameObject.GetComponent <BoxCollider>() != null) { EditorGUILayout.LabelField("Set Box Collider Automatically", EditorStyles.miniBoldLabel); EditorGUILayout.PropertyField(_setColliderAuto); CheckEndChanges(); } else { EditorGUILayout.LabelField("This option required a BoxCollider Component.", EditorStyles.miniLabel); _scrollbar.SetColliderAuto = false; _scrollbar.SetColliderAuto = EditorGUILayout.ToggleLeft("Set Box Collider Automatically", false); // Add a button to replace the collider by a BoxCollider2D if (GUILayout.Button("Add BoxCollider")) { DestroyImmediate(_scrollbar.GetComponent <Collider>()); _scrollbar.gameObject.AddComponent <BoxCollider>(); _scrollbar.SetColliderAuto = true; } } EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Basic ScrollBar Parameters", EditorStyles.boldLabel); EditorGUILayout.Space(); base.OnInspectorGUI(); }
public override void OnInspectorGUI() { EditorGUILayout.Space(); EditorGUILayout.LabelField("VRSF Parameters", EditorStyles.boldLabel); EditorGUILayout.Space(); Undo.RecordObject(vrScrollBar.gameObject, "Add BoxCollider"); if (vrScrollBar.gameObject.GetComponent <BoxCollider>() != null) { vrScrollBar.SetColliderAuto = EditorGUILayout.ToggleLeft("Set Box Collider Automatically", vrScrollBar.SetColliderAuto); } else { EditorGUILayout.LabelField("This option required a BoxCollider Component.", EditorStyles.miniLabel); vrScrollBar.SetColliderAuto = false; vrScrollBar.SetColliderAuto = EditorGUILayout.ToggleLeft("Set Box Collider Automatically", false); // Add a vrScrollBar to replace the collider by a BoxCollider2D if (GUILayout.Button("Add BoxCollider")) { vrScrollBar.gameObject.AddComponent <BoxCollider>(); DestroyImmediate(vrScrollBar.GetComponent <Collider>()); vrScrollBar.SetColliderAuto = true; } } EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Basic ScrollBar Parameters", EditorStyles.boldLabel); EditorGUILayout.Space(); base.OnInspectorGUI(); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); }