Ejemplo n.º 1
0
        public override bool OnPaint(Terrain terrain, IOnPaint editContext)
        {
            Init();

            commonUI.OnPaint(terrain, editContext);

            if (commonUI.allowPaint)
            {
                Vector2 uv = editContext.uv;

                if (commonUI.ScatterBrushStamp(ref terrain, ref uv))
                {
                    BrushTransform brushXform    = TerrainPaintUtility.CalculateBrushTransform(terrain, uv, commonUI.brushSize, commonUI.brushRotation);
                    PaintContext   paintContext  = TerrainPaintUtility.BeginPaintHeightmap(terrain, brushXform.GetBrushXYBounds());
                    float          brushStrength = Event.current.control ? -commonUI.brushStrength : commonUI.brushStrength;

                    Vector3 brushPosWS = WSPosFromTerrainUV(terrain, uv);

                    ApplyBrushInternal(paintContext, brushXform, brushPosWS, commonUI.brushRotation,
                                       brushStrength, commonUI.brushSize, editContext.brushTexture);

                    TerrainPaintUtility.EndPaintHeightmap(paintContext, "Terrain Paint - Noise");
                }
            }
            editContext.Repaint(RepaintFlags.UI);

            return(true);
        }
Ejemplo n.º 2
0
        public override bool OnPaint(Terrain terrain, IOnPaint editContext)
        {
            commonUI.OnPaint(terrain, editContext);

            if (commonUI.allowPaint)
            {
                if (Event.current.control)
                {
                    Terrain currentTerrain = commonUI.terrainUnderCursor;
                    m_TargetHeight = currentTerrain.terrainData.GetInterpolatedHeight(editContext.uv.x, editContext.uv.y) + currentTerrain.GetPosition().y;
                    editContext.Repaint();
                    SaveSetting();
                    return(true);
                }
                else
                {
                    Texture brushTexture = editContext.brushTexture;

                    using (IBrushRenderUnderCursor brushRender = new BrushRenderUIGroupUnderCursor(commonUI, "SetHeightTool", brushTexture))
                    {
                        if (brushRender.CalculateBrushTransform(out BrushTransform brushTransform))
                        {
                            Rect         brushBounds  = brushTransform.GetBrushXYBounds();
                            PaintContext paintContext = brushRender.AcquireHeightmap(true, brushBounds);

                            ApplyBrushInternal(paintContext, brushRender, commonUI.brushStrength, brushTexture, brushTransform, terrain);
                        }
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        public override bool OnPaint(Terrain terrain, IOnPaint editContext)
        {
            if (Event.current.shift)
            {
                m_HeightWorldSpace = terrain.terrainData.GetInterpolatedHeight(editContext.uv.x, editContext.uv.y) + terrain.transform.position.y;
                editContext.Repaint(RepaintFlags.UI);
                return(true);
            }

            BrushTransform brushXform   = TerrainPaintUtility.CalculateBrushTransform(terrain, editContext.uv, editContext.brushSize, 0.0f);
            PaintContext   paintContext = TerrainPaintUtility.BeginPaintHeightmap(terrain, brushXform.GetBrushXYBounds());

            ApplyBrushInternal(paintContext, editContext.brushStrength, editContext.brushTexture, brushXform, terrain);
            TerrainPaintUtility.EndPaintHeightmap(paintContext, "Terrain Paint - Set Height");
            return(true);
        }