Esempio n. 1
0
        public static void OnSceneGUI(Building _building)
        {
            Vector3 position = _building.transform.position;
//            Quaternion rotation = _building.transform.rotation;

            bool shiftIsDown = Event.current.shift;
//            bool controlIsDown = Event.current.control;
//            bool altIsDown = Event.current.alt;

//            Camera sceneCamera = Camera.current;
            Ray     ray           = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);//sceneCamera.ScreenPointToRay(new Vector3(Event.current.mousePosition.x, Screen.height - Event.current.mousePosition.y - 30, 0));
            Event   current       = Event.current;
            IVolume mouseOverPlan = BuildrUtils.OnFloorplanSelectionClick(_building, ray).volume;

//            Volume clickedPlan = null;

            switch (current.type)
            {
            case EventType.MouseMove:
                SceneView.RepaintAll();
                break;

            case EventType.MouseDown:
//                    if (current.button == 0)
//                        clickedPlan = mouseOverPlan;
                break;

            case EventType.ScrollWheel:

                break;
            }

            Vector3 basePosition = position;

            if (BuildingEditor.volume != null)
            {
                basePosition += BuildingEditor.volume.baseHeight * Vector3.up;
            }
            Plane buildingPlane = new Plane(Vector3.up, basePosition);

            Vector3 mousePlanePoint = Vector3.zero;
            float   mouseRayDistance;

            if (buildingPlane.Raycast(ray, out mouseRayDistance))
            {
                mousePlanePoint = ray.GetPoint(mouseRayDistance);
            }
            if (shiftIsDown)
            {
                mousePlanePoint.x = Mathf.Round(mousePlanePoint.x);
                mousePlanePoint.y = Mathf.Round(mousePlanePoint.y);
                mousePlanePoint.z = Mathf.Round(mousePlanePoint.z);
            }
//            float mouseHandleSize = HandleUtility.GetHandleSize(mousePlanePoint) * 0.2f;

            DrawFloorplans(_building, mouseOverPlan);

//            if (clickedPlan != null && clickedPlan != SELECTED_VOLUME)
//            {
//                SELECTED_VOLUME = clickedPlan;
//                Repaint();
//                current.Use();
//            }
        }