Esempio n. 1
0
        public override void OnSceneGUI(Event currentEvent, int controlId, Terrain terrain, IOnSceneGUI editContext)
        {
            base.OnSceneGUI(currentEvent, controlId, terrain, editContext);

            m_JitterHandler.Update();

            if (m_AdjustingSize)
            {
                float size = m_BrushSize.value;

                size += 0.002f * Mathf.Clamp(size, 1.0f, 100.0f) * currentEvent.delta.x;
                m_BrushSize.value = size;

                float pixelPointMultiplier = 1.0f / EditorGUIUtility.pixelsPerPoint;
                var   pos = editContext.sceneView.camera.WorldToScreenPoint(raycastHitUnderCursor.point) * pixelPointMultiplier;
                Handles.BeginGUI();
                {
                    GUI.matrix = Matrix4x4.identity;
                    var temp = TerrainToolGUIHelper.TempContent($"Size: {Mathf.RoundToInt(size)}");
                    GUI.Label(new Rect(pos.x + 10 * pixelPointMultiplier, (Screen.height * pixelPointMultiplier - pos.y - 60 * pixelPointMultiplier), s_SceneLabelStyle.CalcSize(temp).x, EditorGUIUtility.singleLineHeight), temp, s_SceneLabelStyle);
                }
                Handles.EndGUI();
                RequestRepaint();
            }
        }
Esempio n. 2
0
        public override void OnSceneGUI(Event currentEvent, int controlId, Terrain terrain, IOnSceneGUI editContext)
        {
            Event e = Event.current;

            base.OnSceneGUI(currentEvent, controlId, terrain, editContext);

            m_JitterHandler.Update();

            if (m_AdjustingStrength)
            {
                float strength = m_BrushStrength.value;

                strength += 0.001f * e.delta.x;
                m_BrushStrength.value = strength;

                int   strengthPct          = Mathf.RoundToInt(100.0f * strength);
                float pixelPointMultiplier = 1.0f / EditorGUIUtility.pixelsPerPoint;
                var   pos = editContext.sceneView.camera.WorldToScreenPoint(raycastHitUnderCursor.point) * pixelPointMultiplier;
                Handles.BeginGUI();
                {
                    GUI.matrix = Matrix4x4.identity;
                    var temp = TerrainToolGUIHelper.TempContent($"Strength: {strengthPct}%");
                    GUI.Label(new Rect(pos.x + 10 * pixelPointMultiplier, (Screen.height * pixelPointMultiplier - pos.y - 60 * pixelPointMultiplier) - EditorGUIUtility.singleLineHeight, s_SceneLabelStyle.CalcSize(temp).x, EditorGUIUtility.singleLineHeight), temp, s_SceneLabelStyle);
                }
                Handles.EndGUI();
                RequestRepaint();
            }
            else
            {
                m_LastRaycastHit = editContext.raycastHit;
            }
        }
Esempio n. 3
0
        public override void OnSceneGUI(Event currentEvent, int controlId, Terrain terrain, IOnSceneGUI editContext)
        {
            RaycastHit raycastHit = editContext.raycastHit;

            base.OnSceneGUI(currentEvent, controlId, terrain, editContext);
            m_JitterHandler.frequency = m_SmoothJitterFreq.value;
            m_JitterHandler.Update();
            OnSceneEvent(raycastHit, currentEvent.isMouse, currentEvent.type == EventType.MouseDrag);

            if (m_AdjustingRotation && editContext.hitValidTerrain)
            {
                // need to compensate for higher dpi screens
                float pixelPointMultiplier = 1.0f / EditorGUIUtility.pixelsPerPoint;
                var   pos = editContext.sceneView.camera.WorldToScreenPoint(raycastHitUnderCursor.point) * pixelPointMultiplier;
                Handles.BeginGUI();
                {
                    GUI.matrix = Matrix4x4.identity;
                    var temp = TerrainToolGUIHelper.TempContent($"Rotation: {Mathf.RoundToInt(currentRotation)}°");
                    GUI.Label(new Rect(pos.x + 10 * pixelPointMultiplier, (Screen.height * pixelPointMultiplier - pos.y - 60 * pixelPointMultiplier) + EditorGUIUtility.singleLineHeight, s_SceneLabelStyle.CalcSize(temp).x, EditorGUIUtility.singleLineHeight), temp, s_SceneLabelStyle);
                }
                Handles.EndGUI();
                RequestRepaint();
            }
        }