public void UpdateMenu(bool Slider = false)
        {
            if (Slider)
            {
            }
            else
            {
            }

            Min = BrushMini.value / ScmapEditor.Current.Data.size.y;
            Max = BrushMax.value / ScmapEditor.Current.Data.size.y;

            Min /= 10f;
            Max /= 10f;

            if (LastRotation != BrushRotation.intValue)
            {
                LastRotation = BrushRotation.intValue;
                if (LastRotation == 0)
                {
                    BrushGenerator.Current.RotatedBrush = BrushGenerator.Current.Brushes[SelectedFalloff];
                }
                else
                {
                    BrushGenerator.Current.RotatedBrush = BrushGenerator.rotateTexture(BrushGenerator.Current.Brushes[SelectedFalloff], LastRotation);
                }

                TerrainMaterial.SetTexture("_BrushTex", (Texture)BrushGenerator.Current.RotatedBrush);
                BrushGenerator.RegeneratePaintBrushIfNeeded(true);
            }
        }
 public void ChangeFalloff(int id)
 {
     SelectedFalloff = id;
     BrushGenerator.Current.Brushes[SelectedFalloff].wrapMode   = TextureWrapMode.Clamp;
     BrushGenerator.Current.Brushes[SelectedFalloff].mipMapBias = -1f;
     BrushGenerator.Current.Brushes[SelectedFalloff].filterMode = FilterMode.Bilinear;
     BrushGenerator.Current.Brushes[SelectedFalloff].anisoLevel = 2;
     LastRotation = BrushRotation.intValue;
     if (LastRotation == 0)
     {
         BrushGenerator.Current.RotatedBrush = BrushGenerator.Current.Brushes[SelectedFalloff];
     }
     else
     {
         BrushGenerator.Current.RotatedBrush = BrushGenerator.rotateTexture(BrushGenerator.Current.Brushes[SelectedFalloff], LastRotation);
     }
     TerrainMaterial.SetTexture("_BrushTex", (Texture)BrushGenerator.Current.RotatedBrush);
     BrushGenerator.RegeneratePaintBrushIfNeeded(true);
 }
        void Update()
        {
            Invert = Input.GetKey(KeyCode.LeftAlt);
            Smooth = Input.GetKey(KeyCode.LeftShift);

            if (CurrentPage != 0)
            {
                return;
            }

            if (PaintStarted && Input.GetMouseButtonUp(0))
            {
                ScmapEditor.Current.Teren.ApplyDelayedHeightmapModification();
                ScmapEditor.Current.Teren.Flush();
            }

            if (Edit.MauseOnGameplay || ChangingStrength || ChangingSize)
            {
                if (!ChangingSize && (Input.GetKey(KeyCode.M) || ChangingStrength))
                {
                    // Change Strength
                    if (Input.GetMouseButtonDown(0))
                    {
                        ChangingStrength   = true;
                        BeginMousePos      = Input.mousePosition;
                        StrengthBeginValue = BrushStrength.value;
                    }
                    else if (Input.GetMouseButtonUp(0))
                    {
                        ChangingStrength = false;
                    }
                    if (ChangingStrength)
                    {
                        BrushStrength.SetValue((int)Mathf.Clamp(StrengthBeginValue - (BeginMousePos.x - Input.mousePosition.x), 0, 100));
                        //BrushStrengthSlider.value = Mathf.Clamp(StrengthBeginValue - (BeginMousePos.x - Input.mousePosition.x), 0, 100);
                        UpdateMenu(true);
                        //UpdateBrushPosition(true);
                    }
                }
                else if (Input.GetKey(KeyCode.B) || ChangingSize)
                {
                    // Change Size
                    if (Input.GetMouseButtonDown(0))
                    {
                        ChangingSize   = true;
                        BeginMousePos  = Input.mousePosition;
                        SizeBeginValue = BrushSize.value;
                    }
                    else if (Input.GetMouseButtonUp(0))
                    {
                        ChangingSize = false;
                    }
                    if (ChangingSize)
                    {
                        BrushSize.SetValue(Mathf.Clamp(SizeBeginValue - (BeginMousePos.x - Input.mousePosition.x), 1, 256));
                        //BrushSizeSlider.value = Mathf.Clamp(SizeBeginValue - (BeginMousePos.x - Input.mousePosition.x), 1, 256);
                        UpdateMenu(true);
                        UpdateBrushPosition(true);
                    }
                }
                else
                {
                    if (!PaintStarted && Input.GetKey(KeyCode.LeftControl))
                    {
                        if (CameraControler.Current.DragStartedGameplay)
                        {
                            if (UpdateBrushPosition(false))
                            {
                            }
                        }

                        if (Input.GetMouseButton(0))
                        {
                            BrushTarget.SetValue(CameraControler.GetLastScmHeight());
                        }
                        else if (Input.GetMouseButton(1))
                        {
                            BrushMini.SetValue(CameraControler.GetLastScmHeight());
                        }
                        else if (Input.GetMouseButton(2))
                        {
                            BrushMax.SetValue(CameraControler.GetLastScmHeight());
                        }
                    }
                    else if (Edit.MauseOnGameplay && Input.GetMouseButtonDown(0))
                    {
                        if (UpdateBrushPosition(true))
                        {
                            ScmapEditor.Current.Teren.heightmapPixelError = 20;
                            GenerateControlTex.StopGenerateNormal();
                            ScmapEditor.Current.TerrainMaterial.SetFloat("_GeneratingNormal", 1);
                            PaintStarted = true;
                            SymmetryPaint();
                        }
                    }
                    else if (Input.GetMouseButton(0))
                    {
                        if (CameraControler.Current.DragStartedGameplay)
                        {
                            if (UpdateBrushPosition(false))
                            {
                            }
                            SymmetryPaint();
                        }
                    }
                    else if (Input.GetMouseButtonUp(0))
                    {
                        PaintStarted = false;
                        ScmapEditor.Current.Teren.heightmapPixelError = 4;
                        if (Painting)
                        {
                            Painting = false;
                            RegenerateMaps();
                        }
                    }
                    else
                    {
                        UpdateBrushPosition(true);
                    }
                }
            }

            if (TerainChanged && Input.GetMouseButtonUp(0))
            {
                MapLuaParser.Current.History.RegisterTerrainHeightmapChange(beginHeights);
                TerainChanged = false;
            }


            BrushGenerator.RegeneratePaintBrushIfNeeded();
        }
示例#4
0
        void Update()
        {
            Invert = Input.GetKey(KeyCode.LeftAlt);
            Smooth = Input.GetKey(KeyCode.LeftShift);

            if (CurrentPage != 0)
            {
                return;
            }

            if (PaintStarted && Input.GetMouseButtonUp(0))
            {
                ScmapEditor.SyncHeightmap(true);
            }

            if (Edit.MauseOnGameplay || ChangingStrength || ChangingSize)
            {
                if (!ChangingSize && (KeyboardManager.BrushStrengthHold() || ChangingStrength))
                {
                    // Change Strength
                    if (Input.GetMouseButtonDown(0))
                    {
                        ChangingStrength   = true;
                        BeginMousePos      = Input.mousePosition;
                        StrengthBeginValue = BrushStrength.value;
                    }
                    else if (Input.GetMouseButtonUp(0))
                    {
                        ChangingStrength = false;
                    }
                    if (ChangingStrength)
                    {
                        BrushStrength.SetValue((int)Mathf.Clamp(StrengthBeginValue - (BeginMousePos.x - Input.mousePosition.x), 0, 100));
                        //BrushStrengthSlider.value = Mathf.Clamp(StrengthBeginValue - (BeginMousePos.x - Input.mousePosition.x), 0, 100);
                        UpdateMenu(true);
                        //UpdateBrushPosition(true);
                    }
                }
                else if (KeyboardManager.BrushSizeHold() || ChangingSize)
                {
                    // Change Size
                    if (Input.GetMouseButtonDown(0))
                    {
                        ChangingSize   = true;
                        BeginMousePos  = Input.mousePosition;
                        SizeBeginValue = BrushSize.value;
                    }
                    else if (Input.GetMouseButtonUp(0))
                    {
                        ChangingSize = false;
                    }
                    if (ChangingSize)
                    {
                        BrushSize.SetValue(Mathf.Clamp(SizeBeginValue - (BeginMousePos.x - Input.mousePosition.x), 1, 256));
                        //BrushSizeSlider.value = Mathf.Clamp(SizeBeginValue - (BeginMousePos.x - Input.mousePosition.x), 1, 256);
                        UpdateMenu(true);
                        UpdateBrushPosition(true);
                    }
                }
                else
                {
                    if (!PaintStarted && Input.GetKey(KeyCode.LeftControl))
                    {
                        if (CameraControler.Current.DragStartedGameplay)
                        {
                            if (UpdateBrushPosition(false))
                            {
                            }
                        }

                        if (Input.GetMouseButton(0))
                        {
                            BrushTarget.SetValue(CameraControler.GetLastScmHeight());
                        }
                        else if (Input.GetMouseButton(1))
                        {
                            BrushMini.SetValue(CameraControler.GetLastScmHeight());
                        }
                        else if (Input.GetMouseButton(2))
                        {
                            BrushMax.SetValue(CameraControler.GetLastScmHeight());
                        }
                    }
                    else if (Edit.MauseOnGameplay && Input.GetMouseButtonDown(0))
                    {
                        if (UpdateBrushPosition(true))
                        {
                            ScmapEditor.Current.Teren.heightmapPixelError = 20;
                            GenerateControlTex.StopGenerateNormal();
                            ScmapEditor.Current.TerrainMaterial.SetFloat("_GeneratingNormal", 1);
                            PaintStarted = true;
                            RecalcTerrainClamp();
                            SymmetryPaint();
                        }
                    }
                    else if (Input.GetMouseButton(0))
                    {
                        if (CameraControler.Current.DragStartedGameplay)
                        {
                            if (UpdateBrushPosition(false))
                            {
                            }
                            RecalcTerrainClamp();
                            SymmetryPaint();
                        }
                    }
                    else if (Input.GetMouseButtonUp(0))
                    {
                    }
                    else
                    {
                        UpdateBrushPosition(true);
                    }
                }
            }

            if (!CameraControler.IsInputFieldFocused())            // Ignore all unput
            {
                if (Input.GetMouseButton(0))
                {
                }
                else if (KeyboardManager.SwitchTypeNext())
                {
                    int SelectedBrush = 0;
                    for (int i = 0; i < BrushTypes.Length; i++)
                    {
                        if (BrushTypes[i].isOn)
                        {
                            SelectedBrush = i;
                            //BrushTypes[i].isOn = false;
                        }
                    }

                    SelectedBrush++;
                    if (SelectedBrush >= BrushTypes.Length)
                    {
                        SelectedBrush = 0;
                    }

                    BrushTypes[SelectedBrush].isOn = true;
                }
                else if (KeyboardManager.SwitchType1())
                {
                    BrushTypes[0].isOn = true;
                }
                else if (KeyboardManager.SwitchType2())
                {
                    BrushTypes[1].isOn = true;
                }
                else if (KeyboardManager.SwitchType3())
                {
                    BrushTypes[2].isOn = true;
                }
                else if (KeyboardManager.SwitchType4())
                {
                    BrushTypes[3].isOn = true;
                }

                if (KeyboardManager.IncreaseTarget())
                {
                    if (BrushTarget.value < 256)
                    {
                        BrushTarget.SetValue((int)BrushTarget.value + 1);
                    }
                }
                else if (KeyboardManager.DecreaseTarget())
                {
                    if (BrushTarget.value > 0)
                    {
                        BrushTarget.SetValue((int)BrushTarget.value - 1);
                    }
                }
            }


            if (Input.GetMouseButtonUp(0))
            {
                if (TerainChanged)
                {
                    Undo.RegisterUndo(new UndoHistory.HistoryTerrainHeight(), new UndoHistory.HistoryTerrainHeight.TerrainHeightHistoryParameter(beginHeights));
                    TerainChanged = false;
                }

                if (Painting)
                {
                    Painting = false;
                    RegenerateMaps();
                }

                PaintStarted = false;
                ScmapEditor.Current.Teren.heightmapPixelError = 4;
            }



            BrushGenerator.RegeneratePaintBrushIfNeeded();
        }