Пример #1
0
        private void OnEnable()
        {
            this.maxSize = new Vector2(600, 600);

            XmlDocument doc  = new XmlDocument();
            string      path = "Assets/Examples/GUIGames/BWC/Editor/Game_BWC.xml";

            doc.Load(path);
            guiCanvas = new GUICanvas();
            guiCanvas.DeSerialize(doc.DocumentElement);
            WC      = Resources.Load <Texture2D>("bai");
            BC      = Resources.Load <Texture2D>("hei");
            map     = new Map(guiCanvas.Find <Area>("map"));
            wCount  = guiCanvas.Find <Label>("top/count/w/count");
            bCount  = guiCanvas.Find <Label>("top/count/b/count");
            jiesuan = guiCanvas.Find <ImageArea>("jiesuan");


            GameObject go = new GameObject("BG");

            go.hideFlags = HideFlags.DontSave | HideFlags.HideInHierarchy;
            BG           = go.AddComponent <AudioSource>();
            BG.clip      = Resources.Load <AudioClip>("BG");
            BG.Play();
            BG.loop = true;

            go           = new GameObject("sound");
            go.hideFlags = HideFlags.DontSave | HideFlags.HideInHierarchy;
            Sound        = go.AddComponent <AudioSource>();
        }
Пример #2
0
        /// <summary>
        /// Constructs a new timeline and adds it to the specified layout.
        /// </summary>
        /// <param name="layout">Layout to add the timeline GUI to.</param>
        /// <param name="width">Width of the timeline in pixels.</param>
        /// <param name="height">Height of the timeline in pixels.</param>
        public GUITimelineBase(GUILayout layout, int width, int height)
        {
            canvas = new GUICanvas();
            layout.AddElement(canvas);

            SetSize(width, height);
        }
            /// <summary>
            /// Constructs a new gradient key editor control.
            /// </summary>
            /// <param name="parent">GUI layout to attach the child GUI controls to.</param>
            /// <param name="keys">Set of keys to initially display on the editor.</param>
            /// <param name="width">Width of the editor in pixels.</param>
            /// <param name="height">Height of the editor in pixels.</param>
            public GradientKeyEditor(GUILayout parent, ColorGradientKey[] keys, int width, int height)
            {
                canvas = new GUICanvas();
                parent.AddElement(canvas);

                Rebuild(new List <ColorGradientKey>(keys), width, height);
            }
        public void Initialize(ScreenManager screenManager, DefaultRenderer renderer)
        {
            _renderer      = renderer;
            _screenManager = screenManager;

            screenCanvas = new GUICanvas(Vector2.Zero, new Vector2(GameSettings.g_ScreenWidth, GameSettings.g_ScreenHeight), 0, GUIStyle.GUIAlignment.None);

            var baseList = new GuiListToggle(Vector2.Zero, new Vector2(200, 30), 0, GUIStyle.GUIAlignment.TopRight, screenCanvas.Dimensions);

            screenCanvas.AddElement(baseList);

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 35), "return", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject = this,
                ButtonMethod = this.GetType().GetMethod("MainMenu")
            });

            GuiTextBlockLoadDialog textureLoader;

            baseList.AddElement(textureLoader = new GuiTextBlockLoadDialog(Vector2.Zero, new Vector2(200, 35), "image: ", _guiContentLoader, GuiTextBlockLoadDialog.ContentType.Texture2D, GUIRenderer.MonospaceFont, Color.Gray, Color.White)
                                );


            //baseList.AddElement(_sizeBlock = new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Intensity: ", GUIRenderer.MonospaceFont, Color.Gray, Color.White));
            //baseList.AddElement(new GuiSliderFloat(Vector2.Zero, new Vector2(200, 35), 2, 20, Color.Gray, Color.White)
            //{
            //    SliderObject = renderer,
            //    SliderField = typeof(DefaultRenderer).GetField("BokehSize"),
            //    SliderValue = (float)typeof(DefaultRenderer).GetField("BokehSize").GetValue(renderer)
            //});

            renderer._backgroundTextureLoader = textureLoader;

            baseList.ParentResized(screenCanvas.Dimensions);
        }
Пример #5
0
        public void Initialize(ScreenManager screenManager, PixelizerRenderer renderer)
        {
            _renderer      = renderer;
            _screenManager = screenManager;

            screenCanvas = new GUICanvas(Vector2.Zero, new Vector2(GameSettings.g_ScreenWidth, GameSettings.g_ScreenHeight), 0, GUIStyle.GUIAlignment.None);

            baseList = new GuiListToggle(Vector2.Zero, new Vector2(200, 30), 0, GUIStyle.GUIAlignment.TopRight, screenCanvas.Dimensions);
            screenCanvas.AddElement(baseList);

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 35), "return", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject = this,
                ButtonMethod = this.GetType().GetMethod("MainMenu")
            });


            baseList.AddElement(new GUITextBlockToggle(Vector2.Zero, new Vector2(200, 35), "Random points", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ToggleObject = renderer,
                ToggleField  = renderer.GetType().GetField("Random"),
                Toggle       = (bool)renderer.GetType().GetField("Random").GetValue(renderer)
            });

            baseList.AddElement(_splitChance = new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Split Chance: " + renderer.SplitChance, GUIRenderer.MonospaceFont, Color.Gray, Color.White));
            baseList.AddElement(new GuiSliderFloat(Vector2.Zero, new Vector2(200, 35), 0, 1, Color.Gray, Color.White)
            {
                SliderObject = renderer,
                SliderField  = renderer.GetType().GetField("SplitChance"),
                SliderValue  = (float)renderer.GetType().GetField("SplitChance").GetValue(renderer)
            });

            baseList.AddElement(_endChance = new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "End Chance: " + renderer.EndChance, GUIRenderer.MonospaceFont, Color.Gray, Color.White));
            baseList.AddElement(new GuiSliderFloat(Vector2.Zero, new Vector2(200, 35), 0, 1, Color.Gray, Color.White)
            {
                SliderObject = renderer,
                SliderField  = renderer.GetType().GetField("EndChance"),
                SliderValue  = (float)renderer.GetType().GetField("EndChance").GetValue(renderer)
            });

            baseList.AddElement(_scale = new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Scale: " + renderer.Scale, GUIRenderer.MonospaceFont, Color.Gray, Color.White));
            baseList.AddElement(new GuiSliderInt(Vector2.Zero, new Vector2(200, 35), 0, 3, 1, Color.Gray, Color.White)
            {
                SliderObject = renderer,
                SliderField  = renderer.GetType().GetField("Scale"),
                SliderValue  = (int)renderer.GetType().GetField("Scale").GetValue(renderer)
            });

            baseList.AddElement(new GUIColorPicker(Vector2.Zero, new Vector2(200, 200), Color.Gray, GUIRenderer.MonospaceFont)
            {
                ReferenceObject = renderer,
                ReferenceField  = renderer.GetType().GetField("LineColor")
            });

            baseList.AddElement(new GUITextBlock(Vector2.Zero, new Vector2(200, 55), "Click to add effect ", GUIRenderer.MonospaceFont, Color.Gray, Color.White));

            baseList.ParentResized(screenCanvas.Dimensions);
        }
Пример #6
0
        /// <summary>
        /// Constructs a new value display and adds it to the specified layout.
        /// </summary>
        /// <param name="layout">Layout to add the GUI element to.</param>
        /// <param name="width">Width of the timeline in pixels.</param>
        /// <param name="height">Height of the timeline in pixels.</param>
        public GUIGraphValues(GUILayout layout, int width, int height)
        {
            canvas = new GUICanvas();
            layout.AddElement(canvas);

            tickHandler = new GUIGraphTicks();

            SetSize(width, height);
        }
Пример #7
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            VSync = VSyncMode.Adaptive;

            GUICanvas canvas = new GUICanvas();

            canvas.Visible = false;
            GUIRawImage image  = new GUIRawImage();
            GUIButton   button = new GUIButton();

            button.AddChild(image);
            canvas.AddChild(button);

            var go = new GameObject();

            go1 = new GameObject();

            Scene.AddGameObject(go);
            Scene.AddGameObject(go1);

            go.transform.Scale  = new Vector3(1);
            go1.transform.Scale = new Vector3(1);

            go.transform.Position  = new Vector3(0, 0, 0);
            go1.transform.Position = new Vector3(0, 0, 0);

            var tx = go.AddComponent(new TextureRenderer()) as TextureRenderer;

            var txtR = go1.AddComponent(new TextRenderer()) as TextRenderer;

            tx.Effect = new Effect(Shaders.VERTEX, Shaders.FRAGMENT);

            txtR.Effect = new Effect(Shaders.VERTEX, Shaders.FRAGMENT);

            txtR.SetFont(new TextureFont("Content/good.ttf"));
            txtR.SetText("Hello world");

            tx.Texture = new Texture2D("Content/16px.png");

            button.SetXConstraint(new GUIRelativeConstraint(0.2f));
            button.SetYConstraint(new GUIRelativeConstraint(0.2f));
            button.SetWidthConstraint(new GUIRelativeConstraint(0.5f));
            button.SetHeightConstraint(new GUIRelativeConstraint(0.5f));

            image.Texture       = tx.Texture;
            image.RaycastTarget = false;
            button.Graphics     = image;

            image.SetXConstraint(new GUIRelativeConstraint(0f));
            image.SetYConstraint(new GUIRelativeConstraint(0f));
            image.SetHeightConstraint(new GUIRelativeConstraint(1f));
            image.SetWidthConstraint(new GUIRelativeConstraint(1f));

            SceneManager.LoadScene(Scene);
        }
Пример #8
0
        public static T Node <T>(this T self, GUINode element) where T : ParentGUINode
        {
            element.parent = self;
            GUICanvas canvas = element.root as GUICanvas;

            if (canvas != null)
            {
                canvas.TreeChange();
            }
            return(self);
        }
Пример #9
0
        public void Initialize(ScreenManager screenManager, RadialBlurRenderer renderer)
        {
            _renderer      = renderer;
            _screenManager = screenManager;

            screenCanvas = new GUICanvas(Vector2.Zero, new Vector2(GameSettings.g_ScreenWidth, GameSettings.g_ScreenHeight), 0, GUIStyle.GUIAlignment.None);

            baseList = new GuiListToggle(Vector2.Zero, new Vector2(200, 30), 0, GUIStyle.GUIAlignment.TopRight, screenCanvas.Dimensions);
            screenCanvas.AddElement(baseList);

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 35), "return", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject = this,
                ButtonMethod = typeof(RadialBlurGUILogic).GetMethod("MainMenu")
            });

            GuiTextBlockLoadDialog textureLoader;

            baseList.AddElement(textureLoader = new GuiTextBlockLoadDialog(Vector2.Zero, new Vector2(200, 35), "image: ", _guiContentLoader, GuiTextBlockLoadDialog.ContentType.Texture2D, GUIRenderer.MonospaceFont, Color.Gray, Color.White)
                                );


            baseList.AddElement(_intensityBlock = new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Intensity: " + renderer.BlurIntensity, GUIRenderer.MonospaceFont, Color.Gray, Color.White));
            baseList.AddElement(new GuiSliderFloat(Vector2.Zero, new Vector2(200, 35), 0, 1, Color.Gray, Color.White)
            {
                SliderObject = renderer,
                SliderField  = typeof(RadialBlurRenderer).GetField("BlurIntensity"),
                SliderValue  = (float)typeof(RadialBlurRenderer).GetField("BlurIntensity").GetValue(renderer)
            });

            baseList.AddElement(_samplesBlock = new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Samples: " + renderer.BlurSamples, GUIRenderer.MonospaceFont, Color.Gray, Color.White));
            baseList.AddElement(new GuiSliderInt(Vector2.Zero, new Vector2(200, 35), 1, 64, 1, Color.Gray, Color.White)
            {
                SliderObject = renderer,
                SliderField  = typeof(RadialBlurRenderer).GetField("BlurSamples"),
                SliderValue  = (int)typeof(RadialBlurRenderer).GetField("BlurSamples").GetValue(renderer)
            });

            baseList.AddElement(_passBlock = new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Passes: " + renderer.BlurPasses, GUIRenderer.MonospaceFont, Color.Gray, Color.White));
            baseList.AddElement(new GuiSliderInt(Vector2.Zero, new Vector2(200, 35), 1, 3, 1, Color.Gray, Color.White)
            {
                SliderObject = renderer,
                SliderField  = typeof(RadialBlurRenderer).GetField("BlurPasses"),
                SliderValue  = (int)typeof(RadialBlurRenderer).GetField("BlurPasses").GetValue(renderer)
            });

            baseList.AddElement(new GUIBlock(Vector2.Zero, new Vector2(200, 25), Color.DimGray));

            baseList.AddElement(new GUITextBlock(Vector2.Zero, new Vector2(200, 55), "Click to freeze center point ", GUIRenderer.MonospaceFont, Color.Gray, Color.White));

            renderer._backgroundTextureLoader = textureLoader;

            baseList.ParentResized(screenCanvas.Dimensions);
        }
Пример #10
0
        private void OnEnable()
        {
            XmlDocument doc  = new XmlDocument();
            string      path = "Assets/Examples/GUIGames/2048/Resources/Game_2048.xml";

            doc.Load(path);
            guiCanvas = new GUICanvas();
            guiCanvas.DeSerialize(doc.DocumentElement);
            guiCanvas.Find <Button>("ImageArea/up/up").OnClick      = UpClick;
            guiCanvas.Find <Button>("ImageArea/down/left").OnClick  = LeftClick;
            guiCanvas.Find <Button>("ImageArea/down/down").OnClick  = DownClick;
            guiCanvas.Find <Button>("ImageArea/down/right").OnClick = RigntClick;
            guiCanvas.Find <Button>("btn/reset").OnClick            = Reset;
            Reset();
        }
Пример #11
0
        public void Draw(GUICanvas canvas)
        {
            //if (!GameSettings.ui_DrawUI) return;

            _foregroundIndex = 0;
            //_graphicsDevice.SetRenderTarget(null);
            _graphicsDevice.RasterizerState = RasterizerState.CullNone;

            _spriteBatch.Begin();
            canvas.Draw(this, Vector2.Zero, GUIControl.GetMousePosition());

            //Now draw foregroundImages
            for (int index = 0; index <= _foregroundIndex - 1; index++)
            {
                ForegroundImage image = foregroundImages[index];
                DrawImage(image.pos, image.dim, image.tex, image.color, false);
            }
            _spriteBatch.End();
        }
Пример #12
0
        private void OnInitialize()
        {
            canvas = new GUICanvas(GUIOption.FixedWidth(200), GUIOption.FixedHeight(200));

            {
                Vector2I a = new Vector2I(0, 0);
                Vector2I b = new Vector2I(200, 0);
                Vector2I c = new Vector2I(200, 200);
                Vector2I d = new Vector2I(0, 200);

                canvas.DrawTriangleStrip(new Vector2I[] { b, c, a, d }, Color.BansheeOrange);
            }

            {
                Vector2I a = new Vector2I(50, 20);
                Vector2I b = new Vector2I(100, 20);
                Vector2I c = new Vector2I(240, 60);

                Vector2I[] vertices = { c, b };
                canvas.DrawPolyLine(vertices, 1.0f);
            }

            GUI.AddElement(canvas);
        }
Пример #13
0
        public void Initialize(ScreenManager screenManager, BokehRenderer renderer)
        {
            _renderer      = renderer;
            _screenManager = screenManager;

            screenCanvas = new GUICanvas(Vector2.Zero, new Vector2(GameSettings.g_ScreenWidth, GameSettings.g_ScreenHeight), 0, GUIStyle.GUIAlignment.None);

            baseList = new GuiListToggle(Vector2.Zero, new Vector2(200, 30), 0, GUIStyle.GUIAlignment.TopRight, screenCanvas.Dimensions);
            screenCanvas.AddElement(baseList);

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 35), "return", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject = this,
                ButtonMethod = this.GetType().GetMethod("MainMenu")
            });

            GuiTextBlockLoadDialog textureLoader;

            baseList.AddElement(textureLoader = new GuiTextBlockLoadDialog(Vector2.Zero, new Vector2(200, 35), "image: ", _guiContentLoader, GuiTextBlockLoadDialog.ContentType.Texture2D, GUIRenderer.MonospaceFont, Color.Gray, Color.White)
                                );


            baseList.AddElement(_sizeBlock = new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Intensity: " + renderer.BokehSize, GUIRenderer.MonospaceFont, Color.Gray, Color.White));
            baseList.AddElement(new GuiSliderFloat(Vector2.Zero, new Vector2(200, 35), 2, 20, Color.Gray, Color.White)
            {
                SliderObject = renderer,
                SliderField  = typeof(BokehRenderer).GetField("BokehSize"),
                SliderValue  = (float)typeof(BokehRenderer).GetField("BokehSize").GetValue(renderer)
            });

            baseList.AddElement(_brightnessBlock = new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Brightness: " + renderer.Brightness, GUIRenderer.MonospaceFont, Color.Gray, Color.White));
            baseList.AddElement(new GuiSliderFloat(Vector2.Zero, new Vector2(200, 35), 0.1f, 3, Color.Gray, Color.White)
            {
                SliderObject = renderer,
                SliderField  = typeof(BokehRenderer).GetField("Brightness"),
                SliderValue  = (float)typeof(BokehRenderer).GetField("Brightness").GetValue(renderer)
            });

            baseList.AddElement(_downsizeBlock = new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Scale: " + renderer.Downsize, GUIRenderer.MonospaceFont, Color.Gray, Color.White));
            baseList.AddElement(new GuiSliderInt(Vector2.Zero, new Vector2(200, 35), 1, 3, 1, Color.Gray, Color.White)
            {
                SliderObject = renderer,
                SliderField  = renderer.GetType().GetField("Downsize"),
                SliderValue  = (int)renderer.GetType().GetField("Downsize").GetValue(renderer)
            });

            baseList.AddElement(new GUITextBlockToggle(Vector2.Zero, new Vector2(200, 25), "32-bit precision", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ToggleObject = renderer,
                ToggleField  = renderer.GetType().GetField("FullPrecision"),
                Toggle       = renderer.FullPrecision,
            });

            baseList.AddElement(new GUITextBlockToggle(Vector2.Zero, new Vector2(200, 25), "Dynamic Scaling", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ToggleObject = renderer,
                ToggleField  = renderer.GetType().GetField("DynamicScaling"),
                Toggle       = renderer.DynamicScaling,
            });

            baseList.AddElement(new GUIBlock(Vector2.Zero, new Vector2(200, 25), Color.DimGray));

            baseList.AddElement(new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Bokeh Shape: ", GUIRenderer.MonospaceFont, Color.Gray, Color.White));

            //Radio list
            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 25), "Pentagon", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject     = this,
                ButtonMethod     = GetType().GetMethod("SwitchShape"),
                ButtonMethodArgs = new object[] { BokehRenderer.BokehShapes.Pentagon }
            });

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 25), "Hexagon", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject     = this,
                ButtonMethod     = GetType().GetMethod("SwitchShape"),
                ButtonMethodArgs = new object[] { BokehRenderer.BokehShapes.Hexagon }
            });

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 25), "Circle", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject     = this,
                ButtonMethod     = GetType().GetMethod("SwitchShape"),
                ButtonMethodArgs = new object[] { BokehRenderer.BokehShapes.Circle }
            });

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 25), "Star", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject     = this,
                ButtonMethod     = GetType().GetMethod("SwitchShape"),
                ButtonMethodArgs = new object[] { BokehRenderer.BokehShapes.Star }
            });

            baseList.AddElement(new GUIBlock(Vector2.Zero, new Vector2(200, 25), Color.DimGray));

            baseList.AddElement(_polyCount = new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "PolyCount: ", GUIRenderer.MonospaceFont, Color.DimGray, Color.White));


            renderer._backgroundTextureLoader = textureLoader;

            baseList.ParentResized(screenCanvas.Dimensions);
        }
        public void Initialize(ScreenManager screenManager, ParticlePhysicsRenderer renderer)
        {
            _renderer      = renderer;
            _screenManager = screenManager;

            screenCanvas = new GUICanvas(Vector2.Zero, new Vector2(GameSettings.g_ScreenWidth, GameSettings.g_ScreenHeight), 0, GUIStyle.GUIAlignment.None);

            GUIStyle style = new GUIStyle(new Vector2(200, 35), GUIRenderer.MonospaceFont, Color.Gray, Color.White, Color.White, GUIStyle.GUIAlignment.None, GUIStyle.TextAlignment.Left, GUIStyle.TextAlignment.Center, Vector2.Zero, screenCanvas.Dimensions);

            var baseList = new GuiListToggle(Vector2.Zero, new Vector2(200, 30), 0, GUIStyle.GUIAlignment.TopRight, screenCanvas.Dimensions);

            screenCanvas.AddElement(baseList);

            baseList.AddElement(new GUITextBlockButton(style, "return")
            {
                ButtonObject = this,
                ButtonMethod = this.GetType().GetMethod("MainMenu")
            });


            GuiTextBlockLoadDialog textureLoader;

            baseList.AddElement(textureLoader = new GuiTextBlockLoadDialog(style, "image: ", _guiContentLoader, GuiTextBlockLoadDialog.ContentType.Texture2D)
                                );

            baseList.AddElement(new GuiSliderFloatText(style, 0, 1, 2, "K: ")
            {
                SliderObject = renderer,
                SliderField  = renderer.GetType().GetField("SpringConstant"),
                SliderValue  = (float)renderer.GetType().GetField("SpringConstant").GetValue(renderer)
            });

            baseList.AddElement(new GuiSliderFloatText(style, 0, 1, 2, "Dampening: ")
            {
                SliderObject = renderer,
                SliderField  = renderer.GetType().GetField("DampeningConstant"),
                SliderValue  = (float)renderer.GetType().GetField("DampeningConstant").GetValue(renderer)
            });

            baseList.AddElement(new GuiSliderIntText(style, 1, 10, 1, "Scale: ")
            {
                SliderObject = renderer,
                SliderField  = renderer.GetType().GetField("TestInt"),
                SliderValue  = (int)renderer.GetType().GetField("TestInt").GetValue(renderer)
            });

            //baseList.AddElement(new GuiSliderFloatText(Vector2.Zero, new Vector2(200, 55), new Vector2(200, 20), 0, 1, "test", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            //{
            //    SliderObject = renderer,
            //    SliderField = renderer.GetType().GetField("TestFloat"),
            //    SliderValue = (float)renderer.GetType().GetField("TestFloat").GetValue(renderer)
            //});

            //baseList.AddElement(_sizeBlock = new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Intensity: ", GUIRenderer.MonospaceFont, Color.Gray, Color.White));
            //baseList.AddElement(new GuiSliderFloat(Vector2.Zero, new Vector2(200, 35), 2, 20, Color.Gray, Color.White)
            //{
            //    SliderObject = renderer,
            //    SliderField = typeof(DefaultRenderer).GetField("BokehSize"),
            //    SliderValue = (float)typeof(DefaultRenderer).GetField("BokehSize").GetValue(renderer)
            //});

            renderer._backgroundTextureLoader = textureLoader;

            baseList.ParentResized(screenCanvas.Dimensions);
        }
        private void OnInitialize()
        {
            guiOK     = new GUIButton(new LocEdString("OK"));
            guiCancel = new GUIButton(new LocEdString("Cancel"));

            guiOK.OnClick     += OnOK;
            guiCancel.OnClick += OnCancel;

            GUILayout mainVertLayout = GUI.AddLayoutY();

            mainVertLayout.AddSpace(10);

            GUILayout editorHorzLayout = mainVertLayout.AddLayoutX();

            editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING);
            GUIPanel gradientEditorPanel = editorHorzLayout.AddPanel();

            editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING);

            mainVertLayout.AddSpace(15);

            GUILayout buttonHorzLayout = mainVertLayout.AddLayoutX();

            buttonHorzLayout.AddFlexibleSpace();
            buttonHorzLayout.AddElement(guiOK);
            buttonHorzLayout.AddSpace(10);
            buttonHorzLayout.AddElement(guiCancel);
            buttonHorzLayout.AddFlexibleSpace();

            mainVertLayout.AddFlexibleSpace();

            editorPanel = gradientEditorPanel.AddPanel(0);
            GUIPanel editorOverlay = gradientEditorPanel.AddPanel(-1);

            overlayCanvas = new GUICanvas();
            editorOverlay.AddElement(overlayCanvas);

            GUILayout editorVertLayout = editorPanel.AddLayoutY();

            GUILayout guiGradientLayout = editorVertLayout.AddLayoutX();

            guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2);

            texture       = Texture.Create2D(TEX_WIDTH, TEX_HEIGHT);
            spriteTexture = new SpriteTexture(texture);

            guiGradientTexture = new GUITexture(spriteTexture, GUITextureScaleMode.StretchToFit);
            guiGradientTexture.SetHeight(30);

            UpdateTexture();

            guiGradientLayout.AddElement(guiGradientTexture);
            guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2);

            editorVertLayout.AddSpace(10);

            editor = new GradientKeyEditor(editorVertLayout, gradient.GetKeys(), Width - EDITOR_HORZ_PADDING * 2, 20);
            editor.OnGradientModified += colorGradient =>
            {
                gradient = colorGradient;

                UpdateTexture();
                UpdateKeyLines();
            };

            editorVertLayout.AddFlexibleSpace();

            GUITexture containerBg     = new GUITexture(null, EditorStylesInternal.ContainerBg);
            Rect2I     containerBounds = editor.GetBounds(GUI);

            containerBounds.x      -= 2;
            containerBounds.y      -= 2;
            containerBounds.width  += 4;
            containerBounds.height += 6;
            containerBg.Bounds      = containerBounds;

            GUIPanel editorUnderlay = GUI.AddPanel(1);

            editorUnderlay.AddElement(containerBg);

            UpdateKeyLines();

            EditorInput.OnPointerPressed     += OnPointerPressed;
            EditorInput.OnPointerDoubleClick += OnPointerDoubleClicked;
            EditorInput.OnPointerMoved       += OnPointerMoved;
            EditorInput.OnPointerReleased    += OnPointerReleased;
            EditorInput.OnButtonUp           += OnButtonUp;
        }
Пример #16
0
        public void Initialize(MainLogic mainLogic)
        {
            defaultStyle = new GUIStyle(
                dimensionsStyle: new Vector2(200, 25),
                textFontStyle: GUIRenderer.MonospaceFont,
                blockColorStyle: Color.Gray,
                textColorStyle: Color.White,
                sliderColorStyle: Color.Black,
                guiAlignmentStyle: GUIStyle.GUIAlignment.None,
                textAlignmentStyle: GUIStyle.TextAlignment.Left,
                textButtonAlignmentStyle: GUIStyle.TextAlignment.Center,
                textBorderStyle: new Vector2(10, 1),
                parentDimensionsStyle: new Vector2(GameSettings.g_ScreenWidth, GameSettings.g_ScreenHeight));

            screenCanvas = new GUICanvas(Vector2.Zero, new Vector2(GameSettings.g_ScreenWidth, GameSettings.g_ScreenHeight));

            GUIList animationList = new GUIList(Vector2.Zero, new Vector2(200, 70), 0, GUIStyle.GUIAlignment.BottomLeft, screenCanvas.Dimensions);

            animationList.AddElement(new GUITextBlockButton(defaultStyle, "play animation")
            {
                ButtonObject = this,
                ButtonMethod = GetType().GetMethod("PlayAnimation"),
            });
            animationList.AddElement(new GUITextBlockToggle(defaultStyle, "Update Animation")
            {
                ToggleField = typeof(GameSettings).GetField("m_updateAnimation"),
                Toggle      = (bool)typeof(GameSettings).GetField("m_updateAnimation").GetValue(null)
            });

            screenCanvas.AddElement(animationList);

            // MAIN LIST ON THE RIGHT
            baseList = new GuiListToggleScroll(new Vector2(-20, 0), new Vector2(200, 30), 0, GUIStyle.GUIAlignment.TopRight, screenCanvas.Dimensions);
            screenCanvas.AddElement(baseList);


            baseList.AddElement(new GUITextBlockToggle(defaultStyle, "debug info")
            {
                ToggleField = typeof(GameSettings).GetField("ui_debug"),
                Toggle      = (bool)typeof(GameSettings).GetField("ui_debug").GetValue(null)
            });

            //Size of the model
            baseList.AddElement(_sizeBlock = new GUITextBlock(defaultStyle, "Size: " + GameSettings.m_size)
            {
                Dimensions = new Vector2(200, 25)
            });
            baseList.AddElement(new GuiSliderFloat(defaultStyle, -2, 4)
            {
                SliderField = typeof(GameSettings).GetField("m_size"),
                SliderValue = (float)typeof(GameSettings).GetField("m_size").GetValue(null)
            });

            //Basic default orientation buttons, these have slightly different sizes than "default"
            baseList.AddElement(new GUITextBlockButton(defaultStyle, "Center Model")
            {
                ButtonObject = mainLogic,
                ButtonMethod = mainLogic.GetType().GetMethod("CenterModel"),
            });

            baseList.AddElement(new GUITextBlockToggle(defaultStyle, "Orientation: Y")
            {
                ToggleField = typeof(GameSettings).GetField("m_orientationy"),
                Toggle      = (bool)typeof(GameSettings).GetField("m_orientationy").GetValue(null),
            });
            baseList.AddElement(new GUITextBlockToggle(defaultStyle, "Linear Lighting")
            {
                ToggleField = typeof(GameSettings).GetField("r_UseLinear"),
                Toggle      = (bool)typeof(GameSettings).GetField("r_UseLinear").GetValue(null),
            });

            //Main model loader and other loaders
            GuiTextBlockLoadDialog modelLoader;

            baseList.AddElement(modelLoader = new GuiTextBlockLoadDialog(defaultStyle, "Model:", _guiContentLoader, GuiTextBlockLoadDialog.ContentType.Model)
                                );
            mainLogic.modelLoader = modelLoader;

            baseList.AddElement(new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Textures", GUIRenderer.MonospaceFont, Color.DimGray, Color.White, GUIStyle.TextAlignment.Center));
            GuiListToggle textureList = new GuiListToggle(Vector2.Zero, new Vector2(200, 30), 0, GUIStyle.GUIAlignment.None, screenCanvas.Dimensions);

            {
                GuiTextBlockLoadDialog albedoLoader;
                textureList.AddElement(
                    albedoLoader =
                        new GuiTextBlockLoadDialog(defaultStyle, "Albedo:", _guiContentLoader, GuiTextBlockLoadDialog.ContentType.Texture2D));
                mainLogic.albedoLoader = albedoLoader;

                GuiTextBlockLoadDialog normalLoader;
                textureList.AddElement(
                    normalLoader =
                        new GuiTextBlockLoadDialog(defaultStyle, "Normal:", _guiContentLoader, GuiTextBlockLoadDialog.ContentType.Texture2D));
                mainLogic.normalLoader = normalLoader;

                GuiTextBlockLoadDialog roughnessLoader;
                textureList.AddElement(
                    roughnessLoader =
                        new GuiTextBlockLoadDialog(defaultStyle, "Roughness:", _guiContentLoader, GuiTextBlockLoadDialog.ContentType.Texture2D));
                mainLogic.roughnessLoader = roughnessLoader;

                GuiTextBlockLoadDialog metallicLoader;
                textureList.AddElement(
                    metallicLoader =
                        new GuiTextBlockLoadDialog(defaultStyle, "Metallic:", _guiContentLoader, GuiTextBlockLoadDialog.ContentType.Texture2D));
                mainLogic.metallicLoader = metallicLoader;

                GuiTextBlockLoadDialog bumpLoader;
                textureList.AddElement(
                    bumpLoader =
                        new GuiTextBlockLoadDialog(defaultStyle, "Heightmap:", _guiContentLoader, GuiTextBlockLoadDialog.ContentType.Texture2D));
                mainLogic.bumpLoader = bumpLoader;
            }
            baseList.AddElement(textureList);
            textureList.IsToggled = false;

            baseList.AddElement(new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Default Values", GUIRenderer.MonospaceFont, Color.DimGray, Color.White, GUIStyle.TextAlignment.Center));
            GuiListToggle colorList = new GuiListToggle(Vector2.Zero, new Vector2(200, 30), 0, GUIStyle.GUIAlignment.None, screenCanvas.Dimensions);

            {
                colorList.AddElement(new GUIColorPicker(defaultStyle)
                {
                    ReferenceField  = typeof(GameSettings).GetField("bgColor"),
                    ReferenceObject = (Color)typeof(GameSettings).GetField("bgColor").GetValue(null)
                });

                colorList.AddElement(
                    _roughnessBlock =
                        new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Roughness: " + GameSettings.m_roughness,
                                         GUIRenderer.MonospaceFont, Color.Gray, Color.White));
                colorList.AddElement(new GuiSliderFloat(Vector2.Zero, new Vector2(200, 25), 0, 1, Color.Gray, Color.Black)
                {
                    SliderField = typeof(GameSettings).GetField("m_roughness"),
                    SliderValue = (float)typeof(GameSettings).GetField("m_roughness").GetValue(null)
                });

                colorList.AddElement(
                    _metallicBlock =
                        new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Metallic: " + GameSettings.m_metallic,
                                         GUIRenderer.MonospaceFont, Color.Gray, Color.White));
                colorList.AddElement(new GuiSliderFloat(Vector2.Zero, new Vector2(200, 25), 0, 1, Color.Gray, Color.Black)
                {
                    SliderField = typeof(GameSettings).GetField("m_metallic"),
                    SliderValue = (float)typeof(GameSettings).GetField("m_metallic").GetValue(null)
                });
            }
            colorList.IsToggled = false;
            baseList.AddElement(colorList);

            baseList.AddElement(new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Bump Mapping", GUIRenderer.MonospaceFont, Color.DimGray, Color.White, GUIStyle.TextAlignment.Center));
            GuiListToggle parallaxList = new GuiListToggle(Vector2.Zero, new Vector2(200, 30), 0, GUIStyle.GUIAlignment.None, screenCanvas.Dimensions);

            {
                parallaxList.AddElement(new GUITextBlockToggle(Vector2.Zero, new Vector2(200, 40), "Parallax OcclusionMapping", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
                {
                    ToggleField = typeof(GameSettings).GetField("r_UsePOM"),
                    Toggle      = (bool)typeof(GameSettings).GetField("r_UsePOM").GetValue(null)
                });

                parallaxList.AddElement(new GUITextBlockToggle(Vector2.Zero, new Vector2(200, 25), "POM Cutoff", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
                {
                    ToggleField = typeof(GameSettings).GetField("r_POMCutoff"),
                    Toggle      = (bool)typeof(GameSettings).GetField("r_POMCutoff").GetValue(null)
                });

                parallaxList.AddElement(
                    _pomBlock =
                        new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Bump Scale: " + GameSettings.pomScale,
                                         GUIRenderer.MonospaceFont, Color.Gray, Color.White));
                parallaxList.AddElement(new GuiSliderFloat(Vector2.Zero, new Vector2(200, 25), -0.7f, 0.7f, Color.Gray, Color.Black)
                {
                    SliderField = typeof(GameSettings).GetField("pomScale"),
                    SliderValue = (float)typeof(GameSettings).GetField("pomScale").GetValue(null)
                });

                parallaxList.AddElement(
                    _pomQualityBlock =
                        new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "POM Quality: " + GameSettings.r_POMQuality,
                                         GUIRenderer.MonospaceFont, Color.Gray, Color.White));
                parallaxList.AddElement(new GuiSliderFloat(Vector2.Zero, new Vector2(200, 25), 0.5f, 3, Color.Gray, Color.Black)
                {
                    SliderField = typeof(GameSettings).GetField("r_POMQuality"),
                    SliderValue = (float)typeof(GameSettings).GetField("r_POMQuality").GetValue(null)
                });
            }
            parallaxList.IsToggled = false;
            baseList.AddElement(parallaxList);

            //AO

            baseList.AddElement(new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "Ambient Occlusion", GUIRenderer.MonospaceFont, Color.DimGray, Color.White, GUIStyle.TextAlignment.Center));
            GuiListToggle aoList = new GuiListToggle(Vector2.Zero, new Vector2(200, 30), 0, GUIStyle.GUIAlignment.None, screenCanvas.Dimensions);

            {
                aoList.AddElement(new GUITextBlockToggle(Vector2.Zero, new Vector2(200, 25), "Enable AO", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
                {
                    ToggleField = typeof(GameSettings).GetField("ao_Enable"),
                    Toggle      = (bool)typeof(GameSettings).GetField("ao_Enable").GetValue(null)
                });

                aoList.AddElement(
                    _aoRadiiBlock =
                        new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "AO Radius: " + GameSettings.ao_Radii,
                                         GUIRenderer.MonospaceFont, Color.Gray, Color.White));
                aoList.AddElement(new GuiSliderFloat(Vector2.Zero, new Vector2(200, 25), 0, 8, Color.Gray, Color.Black)
                {
                    SliderField = typeof(GameSettings).GetField("ao_Radii"),
                    SliderValue = (float)typeof(GameSettings).GetField("ao_Radii").GetValue(null)
                });

                aoList.AddElement(
                    _aoSamplesBlock =
                        new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "AO Samples ppx: " + GameSettings.ao_Samples,
                                         GUIRenderer.MonospaceFont, Color.Gray, Color.White));

                aoList.AddElement(new GuiSliderInt(Vector2.Zero, new Vector2(200, 25), 0, 64, 2, Color.Gray, Color.Black)
                {
                    SliderField = typeof(GameSettings).GetField("ao_Samples"),
                    SliderValue = (int)typeof(GameSettings).GetField("ao_Samples").GetValue(null)
                });

                aoList.AddElement(
                    _aoStrengthBlock =
                        new GUITextBlock(Vector2.Zero, new Vector2(200, 25), "AO Strength: " + GameSettings.ao_Strength,
                                         GUIRenderer.MonospaceFont, Color.Gray, Color.White));

                aoList.AddElement(new GuiSliderFloat(Vector2.Zero, new Vector2(200, 25), 0, 4, Color.Gray, Color.Black)
                {
                    SliderField = typeof(GameSettings).GetField("ao_Strength"),
                    SliderValue = (float)typeof(GameSettings).GetField("ao_Strength").GetValue(null)
                });

                aoList.AddElement(new GUITextBlockToggle(Vector2.Zero, new Vector2(200, 25), "Blur AO", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
                {
                    ToggleField = typeof(GameSettings).GetField("ao_UseBlur"),
                    Toggle      = (bool)typeof(GameSettings).GetField("ao_UseBlur").GetValue(null)
                });

                aoList.AddElement(new GUITextBlockToggle(Vector2.Zero, new Vector2(200, 25), "Half resolution", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
                {
                    ToggleField = typeof(GameSettings).GetField("ao_HalfRes"),
                    Toggle      = (bool)typeof(GameSettings).GetField("ao_HalfRes").GetValue(null)
                });
            }
            aoList.IsToggled = false;

            baseList.AddElement(aoList);

            UpdateResolution();
        }
Пример #17
0
        /// <summary>
        /// Creates the GUI for the default editor
        /// </summary>
        /// <param name="sceneLogicCamera"></param>
        private void CreateGUI(Camera sceneLogicCamera)
        {
            GuiCanvas = new GUICanvas(Vector2.Zero, new Vector2(GameSettings.g_screenwidth, GameSettings.g_screenheight));

            defaultStyle = new GUIStyle(
                dimensionsStyle: new Vector2(200,35),
                textFontStyle: _assets.MonospaceFont,
                blockColorStyle: Color.Gray, 
                textColorStyle: Color.White,
                sliderColorStyle: Color.White,
                guiAlignmentStyle: GUIStyle.GUIAlignment.None,
                textAlignmentStyle: GUIStyle.TextAlignment.Left,
                textButtonAlignmentStyle: GUIStyle.TextAlignment.Center,
                textBorderStyle: new Vector2(10, 1),
                parentDimensionsStyle: GuiCanvas.Dimensions);

            //Editor gizmo control!
            GuiCanvas.AddElement(_leftSideList = new GUIList(Vector2.Zero, defaultStyle));

            _leftSideList.AddElement(_gizmoTranslation = new GUITextBlockButton(defaultStyle, "Translate (T)")
            {
                ButtonObject = this,
                ButtonMethod = GetType().GetMethod("ChangeGizmoMode"),
                ButtonMethodArgs = new object[]{ EditorLogic.GizmoModes.Translation },
            });
            _leftSideList.AddElement(_gizmoRotation = new GUITextBlockButton(defaultStyle, "Rotate (R)")
            {
                ButtonObject = this,
                ButtonMethod = GetType().GetMethod("ChangeGizmoMode"),
                ButtonMethodArgs = new object[] { EditorLogic.GizmoModes.Rotation },
            });
            _leftSideList.AddElement(_gizmoScale = new GUITextBlockButton(defaultStyle, "Scale (Z)")
            {
                ButtonObject = this,
                ButtonMethod = GetType().GetMethod("ChangeGizmoMode"),
                ButtonMethodArgs = new object[] { EditorLogic.GizmoModes.Scale },
            });
            _leftSideList.AddElement(new GUITextBlockToggle(defaultStyle, "Local: ")
            {
               ToggleField = typeof(GameStats).GetField("e_LocalTransformation"),
                Toggle = GameStats.e_LocalTransformation
            });
            _leftSideList.Alignment = GUIStyle.GUIAlignment.BottomLeft;

            ChangeGizmoMode(EditorLogic.GizmoModes.Translation);

            //Editor options
            GuiCanvas.AddElement(_rightSideList = new GuiListToggleScroll(new Vector2(-20,0), defaultStyle));

            GUITextBlock helperText = new GUITextBlock(new Vector2(0, 100), new Vector2(300, 200), CreateHelperText(), defaultStyle.TextFontStyle, new Color(Color.DimGray, 0.2f), Color.White, GUIStyle.TextAlignment.Left, new Vector2(10, 1)) {IsHidden = true};
            GuiCanvas.AddElement(helperText);

            _rightSideList.AddElement(new GUITextBlockToggle(defaultStyle, "Enable Editor")
            {
                ToggleField = typeof(GameStats).GetField("e_EnableSelection"),
                Toggle = GameStats.e_EnableSelection
            });

            _rightSideList.AddElement(new GUITextBlockToggle(defaultStyle, "Highlight Meshes")
            {
                ToggleField = typeof(GameSettings).GetField("e_drawoutlines"),
                Toggle = GameSettings.e_drawoutlines
            });

            _rightSideList.AddElement(new GUITextBlockToggle(defaultStyle, "Show Controls")
            {
                ToggleProperty = typeof(GUITextBlock).GetProperty("IsVisible"),
                ToggleObject = helperText,
                Toggle = helperText.IsVisible
            });

            _rightSideList.AddElement(new GUITextBlockToggle(defaultStyle, "Default Material")
            {
                ToggleField = typeof(GameSettings).GetField("d_defaultmaterial"),
                Toggle = GameSettings.d_defaultmaterial
            });

            _rightSideList.AddElement(new GuiSliderFloatText(defaultStyle, 0.1f, 3/*(float) (Math.PI - 0.1)*/, 2, "Field Of View: ")
            {
                SliderObject = sceneLogicCamera,
                SliderProperty = typeof(Camera).GetProperty("FieldOfView"),
                SliderValue = sceneLogicCamera.FieldOfView
            });

            //_rightSideList.AddElement(new GuiDropList(defaultStyle, "Show: ")
            //{
            //});

            _rightSideList.AddElement(new GUITextBlock(defaultStyle, "Selection") { BlockColor = Color.DimGray, Dimensions = new Vector2(200, 10), TextAlignment = GUIStyle.TextAlignment.Center });

            GuiListToggle _selectionList = new GuiListToggle(Vector2.Zero, defaultStyle);
            _objectDescriptionList = new GUIList(Vector2.Zero, defaultStyle);

            _objectDescriptionList.AddElement(_objectDescriptionName = new GUITextBlock(defaultStyle, "objDescName"));
            _objectDescriptionList.AddElement(_objectDescriptionPos = new GUITextBlock(defaultStyle, "objDescName"));
            _objectDescriptionList.AddElement(_objectButton1 = new GUITextBlockButton(defaultStyle, "objButton1") {IsHidden = true});
            _objectDescriptionList.AddElement(_objectToggle0 = new GUITextBlockToggle(defaultStyle, "objToggle0") { IsHidden = true });
            _objectDescriptionList.AddElement(_objectToggle1 = new GUITextBlockToggle(defaultStyle, "objToggle1") { IsHidden = true });
            _objectDescriptionList.AddElement(_objectToggle2 = new GUITextBlockToggle(defaultStyle, "objToggle2") { IsHidden = true });
            _objectDescriptionList.AddElement(_objectToggle3 = new GUITextBlockToggle(defaultStyle, "objToggle3") { IsHidden = true });
            _objectDescriptionList.AddElement(_objectSlider0 = new GuiSliderFloatText(defaultStyle, 0,1,2,"objToggle1") { IsHidden = true });
            _objectDescriptionList.AddElement(_objectSlider1 = new GuiSliderFloatText(defaultStyle, 0, 1, 2, "objToggle2") { IsHidden = true });
            _objectDescriptionList.AddElement(_objectSlider2 = new GuiSliderIntText(defaultStyle, 0, 10, 1, "objToggle3") { IsHidden = true });
            _objectDescriptionList.AddElement(_objectColorPicker1 = new GUIColorPicker(defaultStyle) { IsHidden = true });

            _selectionList.AddElement(_objectDescriptionList);
            _rightSideList.AddElement(_selectionList);

            /////////////////////////////////////////////////////////////////
            //Options
            /////////////////////////////////////////////////////////////////
            
            _rightSideList.AddElement(new GUITextBlock(defaultStyle, "Options") {BlockColor = Color.DimGray, Dimensions = new Vector2(200,10), TextAlignment = GUIStyle.TextAlignment.Center});

            GuiListToggle optionList = new GuiListToggle(Vector2.Zero, defaultStyle);
            _rightSideList.AddElement(optionList);

            /////////////////////////////////////////////////////////////////
            //SDF
            /////////////////////////////////////////////////////////////////
            /// 
            optionList.AddElement(new GUITextBlock(Vector2.Zero, new Vector2(200, 10), "SDF",
                defaultStyle.TextFontStyle, Color.DarkSlateGray, Color.White, GUIStyle.TextAlignment.Center,
                Vector2.Zero));

            GuiListToggle sdfList = new GuiListToggle(Vector2.Zero, defaultStyle) { ToggleBlockColor = Color.DarkSlateGray, IsToggled = false };
            optionList.AddElement(sdfList);

            sdfList.AddElement(new GUITextBlockToggle(defaultStyle, "Draw SDF")
            {
                ToggleField = typeof(GameSettings).GetField("sdf_drawdistance"),
                Toggle = GameSettings.sdf_drawdistance
            });

            sdfList.AddElement(new GUITextBlockToggle(defaultStyle, "Draw SDF volume")
            {
                ToggleField = typeof(GameSettings).GetField("sdf_drawvolume"),
                Toggle = GameSettings.sdf_drawvolume
            });

            /////////////////////////////////////////////////////////////////
            //Post Processing
            /////////////////////////////////////////////////////////////////

            optionList.AddElement(new GUITextBlock(defaultStyle, "PostProcessing") { BlockColor = Color.DarkSlateGray, Dimensions = new Vector2(200, 10), TextAlignment = GUIStyle.TextAlignment.Center });

            GuiListToggle postprocessingList = new GuiListToggle(Vector2.Zero, defaultStyle) {ToggleBlockColor = Color.DarkSlateGray, IsToggled = false};
            optionList.AddElement(postprocessingList);

            postprocessingList.AddElement(new GUITextBlockToggle(defaultStyle, "Temporal AA")
            {
                ToggleField = typeof(GameSettings).GetField("g_taa"),
                Toggle = GameSettings.g_taa
            });

            postprocessingList.AddElement(new GUITextBlockToggle(defaultStyle, "Tonemap TAA")
            {
                ToggleField = typeof(GameSettings).GetField("g_taa_tonemapped"),
                Toggle = GameSettings.g_taa_tonemapped
            });

            postprocessingList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 4, 2, "WhitePoint: ")
            {
                SliderProperty = typeof(GameSettings).GetProperty("WhitePoint"),
                SliderValue = GameSettings.WhitePoint
            });

            postprocessingList.AddElement(new GuiSliderFloatText(defaultStyle, -8, 8, 2, "Exposure: ")
            {
                SliderProperty = typeof(GameSettings).GetProperty("Exposure"),
                SliderValue = GameSettings.Exposure
            });

            postprocessingList.AddElement(new GuiSliderFloatText(defaultStyle, -1, 1, 2, "S-Curve: ")
            {
                SliderProperty = typeof(GameSettings).GetProperty("SCurveStrength"),
                SliderValue = GameSettings.SCurveStrength
            });

            postprocessingList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 1, 2, "Chr. Abb.: ")
            {
                SliderProperty = typeof(GameSettings).GetProperty("ChromaticAbberationStrength"),
                SliderValue = GameSettings.ChromaticAbberationStrength
            });

            postprocessingList.AddElement(new GUITextBlockToggle(defaultStyle, "Color Grading")
            {
                ToggleField = typeof(GameSettings).GetField("g_ColorGrading"),
                Toggle = GameSettings.g_ColorGrading
            });

            /////////////////////////////////////////////////////////////////
            //SSR
            /////////////////////////////////////////////////////////////////

            optionList.AddElement(new GUITextBlock(Vector2.Zero, new Vector2(200, 10), "Screen Space Reflections",
                defaultStyle.TextFontStyle, Color.DarkSlateGray, Color.White, GUIStyle.TextAlignment.Center,
                Vector2.Zero));

            GuiListToggle ssrList = new GuiListToggle(Vector2.Zero, defaultStyle) { ToggleBlockColor = Color.DarkSlateGray, IsToggled = false };
            optionList.AddElement(ssrList);

            ssrList.AddElement(new GUITextBlockToggle(defaultStyle, "Enable SSR")
            {
                ToggleProperty = typeof(GameSettings).GetProperty("g_SSReflection"),
                Toggle = GameSettings.g_SSReflection
            });

            ssrList.AddElement(new GUITextBlockToggle(defaultStyle, "Stochastic distr.")
            {
                ToggleProperty = typeof(GameSettings).GetProperty("g_SSReflectionTaa"),
                Toggle = GameSettings.g_SSReflectionTaa
            });

            ssrList.AddElement(new GUITextBlockToggle(defaultStyle, "Temporal Noise")
            {
                ToggleField = typeof(GameSettings).GetField("g_SSReflectionNoise"),
                Toggle = GameSettings.g_SSReflectionNoise
            });

            ssrList.AddElement(new GUITextBlockToggle(defaultStyle, "Firefly Reduction")
            {
                ToggleProperty = typeof(GameSettings).GetProperty("g_SSReflection_FireflyReduction"),
                Toggle = GameSettings.g_SSReflection_FireflyReduction
            });

            ssrList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 5, 2, "Firefly Threshold ")
            {
                SliderProperty = typeof(GameSettings).GetProperty("g_SSReflection_FireflyThreshold"),
                SliderValue = GameSettings.g_SSReflection_FireflyThreshold
            });

            ssrList.AddElement(new GuiSliderIntText(defaultStyle, 1, 100, 1, "Samples: ")
            {
                SliderProperty = typeof(GameSettings).GetProperty("g_SSReflections_Samples"),
                SliderValue = GameSettings.g_SSReflections_Samples
            });

            ssrList.AddElement(new GuiSliderIntText(defaultStyle, 1, 100, 1, "Search Samples: ")
            {
                SliderProperty = typeof(GameSettings).GetProperty("g_SSReflections_RefinementSamples"),
                SliderValue = GameSettings.g_SSReflections_RefinementSamples
            });

            /////////////////////////////////////////////////////////////////
            //SSAO
            /////////////////////////////////////////////////////////////////
            /// 
            optionList.AddElement(new GUITextBlock(Vector2.Zero, new Vector2(200, 10), "Ambient Occlusion",
                defaultStyle.TextFontStyle, Color.DarkSlateGray, Color.White, GUIStyle.TextAlignment.Center,
                Vector2.Zero));

            GuiListToggle ssaoList = new GuiListToggle(Vector2.Zero, defaultStyle) { ToggleBlockColor = Color.DarkSlateGray, IsToggled = false };
            optionList.AddElement(ssaoList);

            ssaoList.AddElement(new GUITextBlockToggle(defaultStyle, "Enable SSAO")
            {
                ToggleProperty = typeof(GameSettings).GetProperty("g_ssao_draw"),
                Toggle = GameSettings.g_ssao_draw
            });

            ssaoList.AddElement(new GUITextBlockToggle(defaultStyle, "SSAO Blur: ")
            {
                ToggleField = typeof(GameSettings).GetField("g_ssao_blur"),
                Toggle = GameSettings.g_ssao_blur
            });

            ssaoList.AddElement(new GuiSliderIntText(defaultStyle, 1, 32, 1, "SSAO Samples: ")
            {
                SliderProperty = typeof(GameSettings).GetProperty("g_ssao_samples"),
                SliderValue = GameSettings.g_ssao_samples
            });

            ssaoList.AddElement(new GuiSliderFloatText(defaultStyle, 1, 100, 2, "Sample Radius: ")
            {
                SliderProperty = typeof(GameSettings).GetProperty("g_ssao_radius"),
                SliderValue = GameSettings.g_ssao_radius
            });

            ssaoList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 4, 1, "SSAO Strength: ")
            {
                SliderProperty = typeof(GameSettings).GetProperty("g_ssao_strength"),
                SliderValue = GameSettings.g_ssao_strength
            });

            /////////////////////////////////////////////////////////////////
            //Bloom
            /////////////////////////////////////////////////////////////////
            /// 
            optionList.AddElement(new GUITextBlock(Vector2.Zero, new Vector2(200, 10), "Bloom",
                defaultStyle.TextFontStyle, Color.DarkSlateGray, Color.White, GUIStyle.TextAlignment.Center,
                Vector2.Zero));

            GuiListToggle bloomList = new GuiListToggle(Vector2.Zero, defaultStyle) { ToggleBlockColor = Color.DarkSlateGray, IsToggled = false };
            optionList.AddElement(bloomList);

            bloomList.AddElement(new GUITextBlockToggle(defaultStyle, "Enable Bloom")
            {
                ToggleField = typeof(GameSettings).GetField("g_BloomEnable"),
                Toggle = GameSettings.g_BloomEnable
            });

            bloomList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 4, 1, "Threshold: ")
            {
                SliderField = typeof(GameSettings).GetField("g_BloomThreshold"),
                SliderValue = GameSettings.g_BloomThreshold
            });

            bloomList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 8, 1, "MIP0 Radius: ")
            {
                SliderField = typeof(GameSettings).GetField("g_BloomRadius1"),
                SliderValue = GameSettings.g_BloomRadius1
            });

            bloomList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 8, 1, "MIP0 Strength: ")
            {
                SliderField = typeof(GameSettings).GetField("g_BloomStrength1"),
                SliderValue = GameSettings.g_BloomStrength1
            });


            bloomList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 8, 1, "MIP1 Radius: ")
            {
                SliderField = typeof(GameSettings).GetField("g_BloomRadius2"),
                SliderValue = GameSettings.g_BloomRadius2
            });

            bloomList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 8, 1, "MIP1 Strength: ")
            {
                SliderField = typeof(GameSettings).GetField("g_BloomStrength2"),
                SliderValue = GameSettings.g_BloomStrength2
            });

            bloomList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 8, 1, "MIP2 Radius: ")
            {
                SliderField = typeof(GameSettings).GetField("g_BloomRadius3"),
                SliderValue = GameSettings.g_BloomRadius3
            });

            bloomList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 8, 1, "MIP2 Strength: ")
            {
                SliderField = typeof(GameSettings).GetField("g_BloomStrength3"),
                SliderValue = GameSettings.g_BloomStrength3
            });

            bloomList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 8, 1, "MIP3 Radius: ")
            {
                SliderField = typeof(GameSettings).GetField("g_BloomRadius4"),
                SliderValue = GameSettings.g_BloomRadius4
            });

            bloomList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 8, 1, "MIP3 Strength: ")
            {
                SliderField = typeof(GameSettings).GetField("g_BloomStrength4"),
                SliderValue = GameSettings.g_BloomStrength4
            });


            bloomList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 8, 1, "MIP4 Radius: ")
            {
                SliderField = typeof(GameSettings).GetField("g_BloomRadius5"),
                SliderValue = GameSettings.g_BloomRadius5
            });

            bloomList.AddElement(new GuiSliderFloatText(defaultStyle, 0, 8, 1, "MIP4 Strength: ")
            {
                SliderField = typeof(GameSettings).GetField("g_BloomStrength5"),
                SliderValue = GameSettings.g_BloomStrength5
            });

            _rightSideList.Alignment = GUIStyle.GUIAlignment.TopRight;
        }
Пример #18
0
        public void ToggleGUILayout()
        {
            ToggleGUI = !ToggleGUI;

            GUICanvas.SetActive(ToggleGUI);
        }
Пример #19
0
 private static extern void Internal_CreateInstance(GUICanvas instance, string style, GUIOption[] options);
Пример #20
0
        public void Initialize(ScreenManager screenManager)
        {
            _screenManager = screenManager;

            screenCanvas = new GUICanvas(Vector2.Zero, new Vector2(GameSettings.g_ScreenWidth, GameSettings.g_ScreenHeight), 0, GUIStyle.GUIAlignment.None);

            baseList = new GUIList(Vector2.Zero, new Vector2(200, 30), 0, GUIStyle.GUIAlignment.Center, screenCanvas.Dimensions);
            screenCanvas.AddElement(baseList);

            //baseList.AddElement(new GUITextBlockToggle(Vector2.Zero, new Vector2(200, 35), "debug info", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            //{
            //    ToggleField = typeof(GameSettings).GetField("ui_debug"),
            //    Toggle = (bool)typeof(GameSettings).GetField("ui_debug").GetValue(null)
            //});

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 35), "Radial Blur", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject     = this,
                ButtonMethod     = GetType().GetMethod("SwitchState"),
                ButtonMethodArgs = new object[] { ScreenManager.ScreenStates.RadialBlur }
            });

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 35), "Pixelizer", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject     = this,
                ButtonMethod     = GetType().GetMethod("SwitchState"),
                ButtonMethodArgs = new object[] { ScreenManager.ScreenStates.Pixelizer }
            });

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 35), "Bokeh", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject     = this,
                ButtonMethod     = GetType().GetMethod("SwitchState"),
                ButtonMethodArgs = new object[] { ScreenManager.ScreenStates.Bokeh }
            });

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 35), "Particle Physics", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject     = this,
                ButtonMethod     = GetType().GetMethod("SwitchState"),
                ButtonMethodArgs = new object[] { ScreenManager.ScreenStates.ParticlePhysics }
            });

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 35), "SSS (WIP)", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject     = this,
                ButtonMethod     = GetType().GetMethod("SwitchState"),
                ButtonMethodArgs = new object[] { ScreenManager.ScreenStates.Subsurface }
            });

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 35), "FourierTransform (WIP)", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject     = this,
                ButtonMethod     = GetType().GetMethod("SwitchState"),
                ButtonMethodArgs = new object[] { ScreenManager.ScreenStates.FourierTransform }
            });

            baseList.AddElement(new GUITextBlockButton(Vector2.Zero, new Vector2(200, 35), "Exit", GUIRenderer.MonospaceFont, Color.Gray, Color.White)
            {
                ButtonObject = this,
                ButtonMethod = GetType().GetMethod("ExitProgram")
            });

            baseList.ParentResized(screenCanvas.Dimensions);
        }
Пример #21
0
        private void OnEnable()
        {
            this.maxSize = new Vector2(600, 500);
            btns.Clear();
            XmlDocument doc  = new XmlDocument();
            string      path = "Assets/Examples/GUIGames/HitMice/Resources/Game_HitMice.xml";

            doc.Load(path);
            guiCanvas = new GUICanvas();
            guiCanvas.DeSerialize(doc.DocumentElement);

            Texture2D hited = guiCanvas.Find <ImageLabel>("hited").image;
            Texture2D Show  = guiCanvas.Find <ImageLabel>("chutou").image;

            score  = 0;
            second = 0;
            guiCanvas.Find <Label>("BG/top/score").text = score.ToString();

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Button btn = guiCanvas.Find <Button>(string.Format("BG/{0}/{1}", i + 1, j + 1));
                    btns.Add(new BtnMice(btns.Count, btn, hited, Show, HitCallBack));
                }
            }
            ImageToggle togEasy     = guiCanvas.Find <ImageToggle>("lev/lev/easy/check");
            ImageToggle togMid      = guiCanvas.Find <ImageToggle>("lev/lev/mid/check");
            ImageToggle togHard     = guiCanvas.Find <ImageToggle>("lev/lev/hard/check");
            ImageToggle togVeryHard = guiCanvas.Find <ImageToggle>("lev/lev/veryHard/check");

            togEasy.value         = true;
            lev                   = 1;
            togEasy.onValueChange = (bo) =>
            {
                if (bo)
                {
                    togVeryHard.value = togMid.value = togHard.value = false;
                    lev = 1;
                }
                else
                {
                    if (!togMid.value && !togHard.value && !togVeryHard.value)
                    {
                        togEasy.value = true;
                    }
                }
            };
            togMid.onValueChange = (bo) =>
            {
                if (bo)
                {
                    togVeryHard.value = togEasy.value = togHard.value = false;
                    lev = 2;
                }
                else
                {
                    if (!togEasy.value && !togHard.value && !togVeryHard.value)
                    {
                        togMid.value = true;
                    }
                }
            };
            togHard.onValueChange = (bo) =>
            {
                if (bo)
                {
                    togVeryHard.value = togMid.value = togEasy.value = false;
                    lev = 3;
                }
                else
                {
                    if (!togMid.value && !togEasy.value && !togVeryHard.value)
                    {
                        togHard.value = true;
                    }
                }
            };
            togVeryHard.onValueChange = (bo) =>
            {
                if (bo)
                {
                    togHard.value = togMid.value = togEasy.value = false;
                    lev           = 6;
                }
                else
                {
                    if (!togMid.value && !togEasy.value && !togHard.value)
                    {
                        togHard.value = true;
                    }
                }
            };

            GameObject go = new GameObject("niganma");

            go.hideFlags = HideFlags.DontSave | HideFlags.HideInHierarchy;
            niganma      = go.AddComponent <AudioSource>();
            niganma.clip = Resources.Load <AudioClip>("niganma");

            go              = new GameObject("jinitaimei");
            go.hideFlags    = HideFlags.DontSave | HideFlags.HideInHierarchy;
            jinitaimei      = go.AddComponent <AudioSource>();
            jinitaimei.clip = Resources.Load <AudioClip>("jinitaimei");
        }