void OnGUI() { if (colorPicker == null) { colorPicker = new IMColorPicker(preset); } using (new GUILayout.HorizontalScope()) { window = GUILayout.Toggle(window, "Window"); } if (window) { colorPicker.DrawWindow(); } else { using (new GUILayout.HorizontalScope()) { GUILayout.Space(10f); using (new GUILayout.VerticalScope()) { GUILayout.Space(10f); GUILayout.Label("IMColorPicker"); colorPicker.DrawColorPicker(); } } } color = colorPicker.color; }
void OnSceneGUI() { int controlId = GUIUtility.GetControlID(FocusType.Passive); if (colorPicker == null) { preset = Resources.Load <IMColorPreset>("imPreset"); colorPicker = new IMColorPicker(preset); } using (new GUILayout.AreaScope(new Rect(20, 20, 200, 200))) { Handles.BeginGUI(); colorPicker.DrawColorPicker(); Handles.EndGUI(); } if (Event.current.type == EventType.Layout) { HandleUtility.AddDefaultControl(controlId); } }