/// <summary> /// Function that handles all the input in the actual scene window /// </summary> void OnSceneGUI() { //Check for edit mode if (Event.current.alt) { inEditMode = false; } else { inEditMode = true; } // if in edit mode, start processing inputs if (inEditMode) { //Disable mouse selection while in edit mode to prevent selection if (Event.current.type == EventType.layout) { HandleUtility.AddDefaultControl(GUIUtility.GetControlID(GetHashCode(), FocusType.Passive)); } if (Event.current.type == EventType.mouseDown) { Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); //cast ray from screen point towards 3d space - super useful RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit, 1000f)) { //if we hit terrain, execute prop instantiation. Vector3 brushPosition = hit.point; worldEditor = (WorldEditor)target; worldEditor.PrefabBrush(brushPosition, (GameObject)prefab); } } } }