public override sealed void OnInspectorGUI()
 {
     KGFGUIUtility.SetSkinIndex(0);
     KGFGUIUtilityEditor.RenderKGFInspector(this, this.GetType(), CustomGui);
     KGFGUIUtility.SetSkinIndex(1);
 }
Beispiel #2
0
    /// <summary>
    /// Draw buttons
    /// </summary>
    void OnGUI()
    {
        float aButtonWidth = 130.0f;

        KGFGUIUtility.SetSkinIndex(1);
        GUILayout.BeginArea(itsRectButtons);
        {
            GUILayout.BeginHorizontal();
            {
                KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
                {
                    GUILayout.BeginHorizontal();
                    {
                        KGFGUIUtility.Label("TEST HERE! ->");
                        GUILayout.FlexibleSpace();
                        GUI.color = new Color(0.5f, 1.0f, 0.5f, 1.0f);
                        if (KGFGUIUtility.Button("follow rot.", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aButtonWidth)))
                        {
                            itsEventSwitchToFollow.Apply();
                            itsCurrentCameraRoot = eCameraRoot.eFollow;
                            itsCutScene.StopCutscene();
                        }
                        if (KGFGUIUtility.Button("follow pos.", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aButtonWidth)))
                        {
                            itsEventSwitchToFollow1.Apply();
                            itsCurrentCameraRoot = eCameraRoot.eFollowPosition;
                            itsCutScene.StopCutscene();
                        }
                        if (KGFGUIUtility.Button("pan + borders", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aButtonWidth)))
                        {
                            itsEventSwitchToPanning.Apply();
                            itsCurrentCameraRoot = eCameraRoot.ePanning;
                            itsCutScene.StopCutscene();
                        }
                        if (KGFGUIUtility.Button("pan world space", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aButtonWidth)))
                        {
                            itsEventSwitchToPanningCameraSpace.Apply();
                            itsCurrentCameraRoot = eCameraRoot.ePanningCamera;
                            itsCutScene.StopCutscene();
                        }
                        if (KGFGUIUtility.Button("lookat", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aButtonWidth)))
                        {
                            itsEventSwitchToInnerCity.Apply();
                            itsCurrentCameraRoot = eCameraRoot.eLake;
                            itsCutScene.StopCutscene();
                        }
                        if (KGFGUIUtility.Button("up side down", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aButtonWidth)))
                        {
                            itsEventSwitchToUpSideDown.Apply();
                            itsCurrentCameraRoot = eCameraRoot.eUpSideDown;
                            itsCutScene.StopCutscene();
                        }
                        GUI.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        KGFGUIUtility.Label("AND HERE! ->");
                        GUILayout.FlexibleSpace();
                        GUI.color = new Color(0.5f, 1.0f, 0.5f, 1.0f);
                        if (KGFGUIUtility.Button("cutscene", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aButtonWidth)))
                        {
                            itsCutScene.StartCutscene();
                        }
                        if (KGFGUIUtility.Button("char. 3rd pers.", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aButtonWidth)))
                        {
                            itsEventSwitchToCapsule.Apply();
                            itsCurrentCameraRoot = eCameraRoot.eCharacter;
                            itsCutScene.StopCutscene();
                        }
                        if (KGFGUIUtility.Button("char. observe", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aButtonWidth)))
                        {
                            itsEventSwitchToObserve.Apply();
                            itsCurrentCameraRoot = eCameraRoot.eObserve;
                            itsCutScene.StopCutscene();
                        }
                        if (KGFGUIUtility.Button("char. isometric", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aButtonWidth)))
                        {
                            itsEventIsometric.Apply();
                            itsCurrentCameraRoot = eCameraRoot.eIsometric;
                            itsCutScene.StopCutscene();
                        }
                        if (KGFGUIUtility.Button("collide", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aButtonWidth)))
                        {
                            itsEventSwitchToCollisions.Apply();
                            itsCurrentCameraRoot = eCameraRoot.eCollision;
                            itsCutScene.StopCutscene();
                        }
                        if (KGFGUIUtility.Button("field of view", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aButtonWidth)))
                        {
                            itsEventSwitchToFishEye.Apply();
                            itsCurrentCameraRoot = eCameraRoot.eFishEye;
                            itsCutScene.StopCutscene();
                        }
                        GUI.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);
                    }
                    GUILayout.EndHorizontal();
                }
                KGFGUIUtility.EndVerticalBox();
            }
            GUILayout.EndHorizontal();
        }
        GUILayout.EndArea();

        KGFGUIUtility.SetSkinIndex(0);
        GUILayout.BeginArea(itsRect);
        {
            GUILayout.BeginVertical();
            {
                GUILayout.FlexibleSpace();
                GUILayout.BeginHorizontal();
                {
                    KGFGUIUtility.Space();
                    GUILayout.Label(itsKOLMICHTexture);
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    KGFGUIUtility.Space();
                    KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
                    {
                        KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop);
                        GUILayout.FlexibleSpace();
                        KGFGUIUtility.Label("CURRENT CAMERA SETTINGS:");
                        GUILayout.FlexibleSpace();
                        KGFGUIUtility.EndHorizontalBox();

                        //target
                        KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
                        KGFGUIUtility.Label("Target:");
                        GUILayout.FlexibleSpace();
                        KGFGUIUtility.EndHorizontalBox();
                        GUILayout.BeginHorizontal();
                        KGFGUIUtility.Label("- gameObject: ");
                        GUILayout.FlexibleSpace();
                        KGFGUIUtility.Label(itsOrbitCam.GetTarget().gameObject.name);
                        GUILayout.EndHorizontal();
                        float aFollowPositionSpeed = DrawFloat("- follow pos. speed:", itsOrbitCam.GetTargetFollowPositionSpeed(), true, 1.0f, 20.0f);
                        float aFollowRotationSpeed = DrawFloat("- follow rot. speed:", itsOrbitCam.GetTargetFollowRotationSpeed(), true, 1.0f, 20.0f);
                        itsOrbitCam.SetTargetFollowPositionSpeed(aFollowPositionSpeed);
                        itsOrbitCam.SetTargetFollowRotationSpeed(aFollowRotationSpeed);

                        //zoom
                        KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
                        KGFGUIUtility.Label("Zoom:");
                        GUILayout.FlexibleSpace();
                        KGFGUIUtility.EndHorizontalBox();
                        bool anEnabled = DrawBoolean("- enabled: ", itsOrbitCam.GetZoomEnable());
                        itsOrbitCam.SetZoomEnable(anEnabled);
                        float aMinLimit = DrawFloat("- min limit:", itsOrbitCam.GetZoomMinLimit(), itsOrbitCam.GetZoomUseLimits(), 0.5f, 20.0f);
                        float aMaxLimit = DrawFloat("- max limit:", itsOrbitCam.GetZoomMaxLimit(), itsOrbitCam.GetZoomUseLimits(), 0.5f, 20.0f);
                        if (itsOrbitCam.GetZoomUseLimits())
                        {
                            itsOrbitCam.SetZoomMinLimit(aMinLimit);
                            itsOrbitCam.SetZoomMaxLimit(aMaxLimit);
                        }

                        //rotation horizontal
                        KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
                        KGFGUIUtility.Label("Horizontal rotation:");
                        GUILayout.FlexibleSpace();
                        KGFGUIUtility.EndHorizontalBox();
                        anEnabled = DrawBoolean("- enabled: ", itsOrbitCam.GetRotationHorizontalEnable());
                        itsOrbitCam.SetRotationHorizontalEnable(anEnabled);
                        float aLeftLimit  = DrawFloat("- left limit:", itsOrbitCam.GetRotationHorizontalLeftLimit(), itsOrbitCam.GetRotationHorizontalUseLimits(), 0.0f, 180.0f);
                        float aRightLimit = DrawFloat("- right limit:", itsOrbitCam.GetRotationHorizontalRightLimit(), itsOrbitCam.GetRotationHorizontalUseLimits(), 0.0f, 180.0f);
                        if (itsOrbitCam.GetRotationHorizontalUseLimits())
                        {
                            itsOrbitCam.SetRotationHorizontalLeftLimit(aLeftLimit);
                            itsOrbitCam.SetRotationHorizontalRightLimit(aRightLimit);
                        }

                        //rotation vertical
                        KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
                        KGFGUIUtility.Label("Vertical rotation:");
                        GUILayout.FlexibleSpace();
                        KGFGUIUtility.EndHorizontalBox();
                        anEnabled = DrawBoolean("- enabled: ", itsOrbitCam.GetRotationVerticalEnable());
                        itsOrbitCam.SetRotationVerticalEnable(anEnabled);
                        float anUpLimit  = DrawFloat("- up limit:", itsOrbitCam.GetRotationVerticalUpLimit(), itsOrbitCam.GetRotationVerticalUseLimits(), 0.0f, 180.0f);
                        float aDownLimit = DrawFloat("- down limit:", itsOrbitCam.GetRotationVerticalDownLimit(), itsOrbitCam.GetRotationVerticalUseLimits(), 0.0f, 180.0f);
                        if (itsOrbitCam.GetRotationVerticalUseLimits())
                        {
                            itsOrbitCam.SetRotationVerticalUpLimit(anUpLimit);
                            itsOrbitCam.SetRotationVerticalDownLimit(aDownLimit);
                        }

                        //panning left right
                        KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
                        KGFGUIUtility.Label("Panning:");
                        GUILayout.FlexibleSpace();
                        KGFGUIUtility.EndHorizontalBox();

                        float aSpeed = DrawFloat("- speed: ", itsOrbitCam.GetPanningSpeed(), true, 1.0f, 10.0f);
                        itsOrbitCam.SetPanningSpeed(aSpeed);
                        anEnabled = DrawBoolean("- left right enabled: ", itsOrbitCam.GetPanningLeftRightEnable());
//						itsOrbitCam.SetPanningLeftRightEnable(anEnabled);
                        anEnabled = DrawBoolean("- forward backward enabled: ", itsOrbitCam.GetPanningForwardBackwardEnable());
//						itsOrbitCam.SetPanningForwardBackwardEnable(anEnabled);
                        anEnabled = DrawBoolean("- up down enabled: ", itsOrbitCam.GetPanningUpDownEnable());
//						itsOrbitCam.SetPanningUpDownEnable(anEnabled);

                        //camera
                        KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
                        KGFGUIUtility.Label("Camera:");
                        GUILayout.FlexibleSpace();
                        KGFGUIUtility.EndHorizontalBox();
                        float aFieldOfView = DrawFloat("- field of view: ", itsOrbitCam.GetCameraFieldOfView(), true, 45.0f, 179.0f);
                        itsOrbitCam.SetCameraFieldOfView(aFieldOfView);

                        //lookat target
                        KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
                        KGFGUIUtility.Label("Lookat:");
                        GUILayout.FlexibleSpace();
                        KGFGUIUtility.EndHorizontalBox();
                        GUILayout.BeginHorizontal();
                        KGFGUIUtility.Label("- target: ");
                        GUILayout.FlexibleSpace();
                        if (itsOrbitCam.GetLookatTarget() != null)
                        {
                            KGFGUIUtility.Label(itsOrbitCam.GetLookatTarget().gameObject.name);
                        }
                        else
                        {
                            KGFGUIUtility.Label("NO TARGET");
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal();
                        KGFGUIUtility.Label("- up vector target: ");
                        GUILayout.FlexibleSpace();
                        if (itsOrbitCam.GetLookatUpVectorSource() != null)
                        {
                            KGFGUIUtility.Label(itsOrbitCam.GetLookatUpVectorSource().gameObject.name);
                        }
                        else
                        {
                            KGFGUIUtility.Label("NO TARGET");
                        }
                        GUILayout.EndHorizontal();
                    }
                    KGFGUIUtility.EndVerticalBox();
                }
                GUILayout.EndHorizontal();
            }
            KGFGUIUtility.Space();
            GUILayout.EndVertical();
        }
        GUILayout.EndArea();
    }
Beispiel #3
0
    public static void Render()
    {
        KGFGUIUtility.SetSkinIndex(0);
        if (itsInstance != null && itsInstance.itsDataModuleCustomGUI.itsBarVisible)
        {
            GUIStyle aTogglStyle = KGFGUIUtility.GetStyleToggl(KGFGUIUtility.eStyleToggl.eTogglRadioStreched);
            GUIStyle aBoxStyle   = KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
            int      aWidth      = (int)(aTogglStyle.contentOffset.x + aTogglStyle.padding.horizontal + (KGFGUIUtility.GetSkinHeight() - aTogglStyle.padding.vertical));
            int      aHeight     = (int)(aBoxStyle.margin.top + aBoxStyle.margin.bottom + aBoxStyle.padding.top + aBoxStyle.padding.bottom
                                         + (aTogglStyle.fixedHeight + aTogglStyle.margin.top) * itsCustomGuiList.Count);

            GUILayout.BeginArea(new Rect(Screen.width - aWidth, (Screen.height - aHeight) / 2, aWidth, aHeight));
            {
                KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                {
                    GUILayout.FlexibleSpace();

                    foreach (KGFICustomGUI aCustomGUI in itsCustomGuiList)
                    {
                        bool aValue;

                        if (itsCurrentSelectedGUI != null && itsCurrentSelectedGUI == aCustomGUI)
                        {
                            aValue = true;
                        }
                        else
                        {
                            aValue = false;
                        }

                        Texture2D aIcon = aCustomGUI.GetIcon();

                        if (aIcon == null)
                        {
                            aIcon = itsInstance.itsDataModuleCustomGUI.itsUnknownIcon;
                        }

                        if (aValue != KGFGUIUtility.Toggle(aValue, aIcon, KGFGUIUtility.eStyleToggl.eTogglRadioStreched))
                        {
                            if (aValue)
                            {
                                itsCurrentSelectedGUI = null;
                            }
                            else
                            {
                                itsCurrentSelectedGUI = aCustomGUI;
                            }
                        }
                    }

                    GUILayout.FlexibleSpace();
                }
                KGFGUIUtility.EndVerticalBox();
            }
            GUILayout.EndArea();

            itsInstance.DrawCurrentCustomGUI(aWidth);

            #region old render code

            /*
             *
             * float aButtonSpaceHorizontal = Math.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16);
             * float aButtonSpaceVertical = Math.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16);
             * int aBoxSpaceHorizontal = Math.Max(KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).margin.horizontal + KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).padding.horizontal, 24);
             * int aBoxSpaceVertical = Math.Max(KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).margin.vertical + KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).padding.vertical, 24);
             *
             * GUILayout.BeginArea(new Rect(Screen.width - (aBoxSpaceHorizontal + aButtonSpaceHorizontal / 2),
             *                           Screen.height / 2 - ((itsCustomGUIImplementations.Count * aButtonSpaceVertical) + aBoxSpaceHorizontal) / 2,
             *                           aButtonSpaceHorizontal + aBoxSpaceHorizontal,
             *                           (itsCustomGUIImplementations.Count * aButtonSpaceVertical) + aBoxSpaceVertical));
             *
             * {
             *      KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated, GUILayout.MinWidth(24));
             *      {
             *              foreach(KGFICustomGUI aCustomGUI in itsCustomGUIImplementations)
             *              {
             *                      bool selected = false;
             *                      float aWidth = Mathf.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16);
             *
             *                      if(aCustomGUI.GetIcon() != null)
             *                      {
             *                              if(KGFGUIUtility.Button(aCustomGUI.GetIcon(), KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth)))
             *                              {
             *                                      selected = true;
             *                              }
             *                      }
             *                      else
             *                      {
             *                              if(itsUnknownIcon != null)
             *                              {
             *                                      if(KGFGUIUtility.Button(itsUnknownIcon, KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth)))
             *                                      {
             *                                              selected = true;
             *                                      }
             *                              }
             *                              else
             *                              {
             *                                      if(KGFGUIUtility.Button("?", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth)))
             *                                      {
             *                                              selected = true;
             *                                      }
             *                              }
             *                      }
             *
             *                      // check if one of the Buttons was clicked
             *                      if(selected && aCustomGUI != itsCurrentSelectedGUI)
             *                      {
             *                              itsCurrentSelectedGUI = aCustomGUI;
             *                      }
             *                      else if(selected && aCustomGUI == itsCurrentSelectedGUI)
             *                      {
             *                              itsCurrentSelectedGUI = null;
             *                      }
             *              }
             *      }
             *      KGFGUIUtility.EndVerticalBox();
             * }
             * GUILayout.EndArea();
             *
             * //Draw the Custom GUI
             * if(itsCurrentSelectedGUI != null)
             * {
             *      itsWindowRectangle = KGFGUIUtility.Window(0, itsWindowRectangle, itsInstance.DrawCurrentCustomGUI,string.Empty, GUILayout.MinHeight(200), GUILayout.MinWidth(300));
             *
             *      // check if the window is still visible in screen
             *      if(itsWindowRectangle.x < -itsWindowRectangle.width + 20)
             *      {
             *              itsWindowRectangle.x = -itsWindowRectangle.width + 20;
             *      }
             *      else if(itsWindowRectangle.x > Screen.width - 20)
             *      {
             *              itsWindowRectangle.x = Screen.width - 20;
             *      }
             *
             *      if(itsWindowRectangle.y < -itsWindowRectangle.height + 20)
             *      {
             *              itsWindowRectangle.y = -itsWindowRectangle.height + 20;
             *      }
             *      else if(itsWindowRectangle.y > Screen.height - 20)
             *      {
             *              itsWindowRectangle.y = Screen.height - 20;
             *      }
             * }
             * }
             */
            #endregion
        }
        KGFGUIUtility.SetSkinIndex(1);
    }