private void DrawInstruction() { string s = string.Format( "{0}" + "{1}" + "{2}" + "{3}", "Click to select,", "\nShift+Click to add,", "\nCtrl+Click to remove anchor.", "\nClick End Editing Spline when done."); GUIContent mouseMessage = new GUIContent(s); PEditorCommon.SceneViewMouseMessage(mouseMessage); }
private void HandleAddRemoveTiles() { Plane plane = new Plane(Vector3.up, water.transform.position); Ray r = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); float distance = -1; if (plane.Raycast(r, out distance)) { Vector3 hitWorldPos = r.origin + r.direction * distance; Vector3 hitLocalPos = water.transform.InverseTransformPoint(hitWorldPos); PIndex2D index = new PIndex2D( Mathf.FloorToInt(hitLocalPos.x / water.TileSize.x), Mathf.FloorToInt(hitLocalPos.z / water.TileSize.y)); Vector3 rectCenter = water.transform.TransformPoint(new Vector3( (index.X + 0.5f) * water.TileSize.x, hitLocalPos.y, (index.Z + 0.5f) * water.TileSize.y)); Vector3 rectSize = water.transform.TransformVector(new Vector3( water.TileSize.x, 0, water.TileSize.y)); if (Event.current.type == EventType.MouseDrag || Event.current.type == EventType.MouseUp) { if (Event.current.button != 0) { return; } if (Event.current.control) { water.TileIndices.Remove(index); water.ReCalculateBounds(); } else if (Event.current.shift) { if (!water.TileIndices.Contains(index)) { water.TileIndices.Add(index); water.ReCalculateBounds(); } } PUtilities.MarkCurrentSceneDirty(); EditorUtility.SetDirty(water); } Handles.color = Handles.selectedColor; Handles.DrawWireCube(rectCenter, rectSize); string s = string.Format( "{0}" + "{1}" + "{2}", index.ToString(), "\nShift+Click to pin, Ctrl+Click to unpin water planes.", "\nClick End Editing Tiles when done."); GUIContent mouseMessage = new GUIContent(s); PEditorCommon.SceneViewMouseMessage(mouseMessage); } }