Beispiel #1
0
        public static void OnSceneViewGUI(SceneView sv)
        {
            Event e = Event.current;

            if (e == null)
            {
                return;
            }
            int controlId = EditorGUIUtility.GetControlID(FocusType.Passive, sv.position);

            if (e.type == EventType.DragUpdated)
            {
                Object[] draggedObjects = DragAndDrop.objectReferences;
                if (draggedObjects.Length == 1 &&
                    draggedObjects[0] is GTerrainData)
                {
                    DragAndDrop.AcceptDrag();
                    DragAndDrop.visualMode      = DragAndDropVisualMode.Generic;
                    DragAndDrop.activeControlID = controlId;
                    e.Use();
                }
            }
            else if (e.type == EventType.DragPerform)
            {
                Object[] draggedObjects = DragAndDrop.objectReferences;
                if (draggedObjects.Length == 1 &&
                    draggedObjects[0] is GTerrainData)
                {
                    GTerrainData data = draggedObjects[0] as GTerrainData;
                    GCommon.CreateTerrain(data);
                    e.Use();
                }
            }
        }
Beispiel #2
0
        private static void OnHierarchyGUI(int instanceID, Rect r)
        {
            Event e = Event.current;

            if (e == null)
            {
                return;
            }
            int controlId = EditorGUIUtility.GetControlID(FocusType.Passive);

            if (e.type == EventType.DragUpdated)
            {
                Object[] draggedObjects = DragAndDrop.objectReferences;
                if (draggedObjects.Length == 1 &&
                    draggedObjects[0] is GTerrainData)
                {
                    DragAndDrop.AcceptDrag();
                    DragAndDrop.visualMode      = DragAndDropVisualMode.Generic;
                    DragAndDrop.activeControlID = controlId;
                    e.Use();
                }
            }
            else if (e.type == EventType.DragPerform)
            {
                Object[] draggedObjects = DragAndDrop.objectReferences;
                if (draggedObjects.Length == 1 &&
                    draggedObjects[0] is GTerrainData)
                {
                    GTerrainData data = draggedObjects[0] as GTerrainData;
                    GCommon.CreateTerrain(data);
                    data.Geometry.ClearDirtyRegions();
                    data.Foliage.ClearTreeDirtyRegions();
                    data.Foliage.ClearGrassDirtyRegions();
                    e.Use();
                }
            }
        }