示例#1
0
        private void SetupInputManager()
        {
            inputManager = new InputManager();

            var undoTrigger = new KeyCombination()
                              .Ctrl()
                              .Key(KeyCode.Z)
                              .AddTriggeredCallback(undoRedoManager.Undo);

            inputManager.AddTrigger(undoTrigger);

            var redoTrigger = new KeyCombination()
                              .Ctrl()
                              .Shift()
                              .Key(KeyCode.Z)
                              .AddTriggeredCallback(undoRedoManager.Redo);

            inputManager.AddTrigger(redoTrigger);

            var skyboxRotationTrigger = new KeyCombination()
                                        .Shift()
                                        .Key(KeyCode.Mouse0, KeyTriggerType.Press)
                                        .AddTriggeredCallback(() =>
            {
                var lastMousePosition = UnityMemorizer <Vector3> .Instance.GetValue("mousePosition");
                var mousePosition     = Input.mousePosition;
                var rotation          = mousePosition.x - lastMousePosition.x;
                SkyboxUtility.RotateSkyBoxIncremental(rotation);
            });

            inputManager.AddTrigger(skyboxRotationTrigger);

            var paintTrigger = new KeyCombination()
                               .Key(KeyCode.Mouse0, KeyTriggerType.Press)
                               .AddTriggeredCallback(() =>
            {
                bool isHit = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit);

                if (isHit)
                {
                    var point = new Vector2(hit.point.x, hit.point.z);
                    paintingManager.PaintTriggered(point);
                }
            })
                               .AddNotTriggeredCallback(paintingManager.PaintNotTriggered);

            inputManager.AddTrigger(paintTrigger);

            var invertBrushColorTrigger = new KeyCombination()
                                          .Key(KeyCode.X)
                                          .AddTriggeredCallback(() =>
            {
                var color    = paintingManager.Brush.TintColor;
                var newColor = new Color(1f - color.r, 1f - color.g, 1f - color.b, color.a);
                paintingManager.Brush.TintColor = newColor;
            });

            inputManager.AddTrigger(invertBrushColorTrigger);
        }
示例#2
0
        private void SetupUI()
        {
            SetupBrushSettings();
            SetupMainSettings();

            layerStackPresenter = new LayerStackPresenter(layerStackViewData, contextMenuViewData, stack);
            resourcesPresenter  = new ResourcesPresenter(resourcesViewData, contextMenuViewData, resourceManager);

            void SetupBrushSettings()
            {
                Assert.NotNull(brushSizeSlider, nameof(brushSizeSlider));
                Assert.NotNull(brushPressureSlider, nameof(brushPressureSlider));
                Assert.NotNull(brushHardnessSlider, nameof(brushHardnessSlider));
                Assert.NotNull(brushColorSlider, nameof(brushColorSlider));

                brushSizeSlider.value = paintingManager.Brush.PercentageSize.x;
                brushSizeSlider.onValueChanged.AddListener(v => paintingManager.Brush.PercentageSize = new Vector2(v, v));

                brushPressureSlider.value = paintingManager.Brush.TintColor.a;
                brushPressureSlider.onValueChanged.AddListener(v =>
                {
                    var color = paintingManager.Brush.TintColor;
                    color.a   = v;
                    paintingManager.Brush.TintColor = color;
                });

                brushHardnessSlider.value = (paintingManager.Brush as DefaultRoundBrush).Hardness;
                brushHardnessSlider.onValueChanged.AddListener(v => (paintingManager.Brush as DefaultRoundBrush).Hardness = v);

                brushColorSlider.value = paintingManager.Brush.TintColor.r;
                paintingManager.Brush.PropertyChanged += (s, e) =>
                {
                    if (e.propertyName == "TintColor")
                    {
                        brushColorSlider.value = paintingManager.Brush.TintColor.r;
                    }
                };
                brushColorSlider.onValueChanged.AddListener(v =>
                {
                    var alpha = paintingManager.Brush.TintColor.a;
                    var color = new Color(v, v, v, alpha);
                    paintingManager.Brush.TintColor = color;
                });
            }

            void SetupMainSettings()
            {
                Assert.NotNull(textureResolutionDropdown, nameof(textureResolutionDropdown));
                //Assert.NotNull (surfaceWorldSizeDropdown, nameof (surfaceWorldSizeDropdown));
                Assert.NotNull(skyboxRotationSlider, nameof(skyboxRotationSlider));
                Assert.NotNull(skyboxBlurSlider, nameof(skyboxBlurSlider));

                textureResolutionDropdown.value = (int)Mathf.Log(context.TextureResolution.AsInt, 2) - 9;
                textureResolutionDropdown.onValueChanged.AddListener(v =>
                {
                    var resolution = (TextureResolutionEnum)(Mathf.Pow(2, v + 9));
                    context.TextureResolution.SetResolution(resolution);
                });

                skyboxRotationSlider.value    = Mathf.Clamp01(SkyboxUtility.SkyboxRotation / 360f);
                SkyboxUtility.OnSkyboxRotate += ()
                                                => skyboxRotationSlider.value = Mathf.Clamp01(SkyboxUtility.SkyboxRotation / 360f);
                skyboxRotationSlider.onValueChanged.AddListener(v => SkyboxUtility.RotateSkybox(v * 360));

                skyboxBlurSlider.value = SkyboxUtility.SkyboxBlurriness;
                skyboxBlurSlider.onValueChanged.AddListener(v => SkyboxUtility.SetSkyboxBlurAmount(v));
            }
        }
示例#3
0
 private void SetupSkyboxUtility()
 {
     SkyboxUtility.SetSkyboxCubeMap(Resources.Load("Textures/Cubemaps/DefaultCubeMap") as Cubemap);
 }