public override void OnInspectorGUI() { DrawDefaultInspector(); if (surface == null) { surface = (BaseSpherePointsEditor)target; surface.SetEditMode(inEditMode = false); } if (GUILayout.Button("Refresh Points")) { surface.RefreshPoints(); } if (GUILayout.Button("Edit", Styles.GetToggleButtonStyleByState(inEditMode))) { surface.SetEditMode(inEditMode = !inEditMode); SetChildrenRenderState(inEditMode ? EditorSelectedRenderState.Hidden : EditorSelectedRenderState.Highlight); } GUILayout.Label(helpLabel); if (GUILayout.Button("Clear all spheres")) { surface.spheres.Clear(); } }
protected virtual void OnSceneGUI() { Event e = Event.current; if (!inEditMode || e.button != 0) { return; } if (surface == null) { surface = (BaseSpherePointsEditor)target; } if (e.isMouse) { if (e.type == EventType.MouseDown) { if (inEditMode) { blockingMouseInput = true; ClickOnSurface(e); } } else if (e.type == EventType.MouseDrag) { //TODO: drag spheres } else if (e.type == EventType.MouseMove) { if (editSingleSphere) { surface.ChangeRadius((e.mousePosition - lastMousePos) * relativeSizeChange); } lastMousePos = e.mousePosition; } else if (e.type == EventType.MouseUp) { if (blockingMouseInput) { e.Use(); } blockingMouseInput = false; } } else if (e.type == EventType.Layout && inEditMode) { HandleUtility.AddDefaultControl(GUIUtility.GetControlID(GetHashCode(), FocusType.Passive)); } SceneView.RepaintAll(); }