Ejemplo n.º 1
0
        internal void DiplayMenu(CameraPlusBehaviour parentBehaviour, ContextMenu contextMenu, Vector2 menuPos)
        {
            GUI.Box(new Rect(menuPos.x, menuPos.y + 25, 300, 120), "Select scene to import from Camera2");
            if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 50, 140, 25), new GUIContent("<")))
            {
                Camera2ConfigExporter.TrySceneSetLast(Camera2ConfigExporter.currentlyScenesSelected);
            }
            if (GUI.Button(new Rect(menuPos.x + 155, menuPos.y + 50, 140, 25), new GUIContent(">")))
            {
                Camera2ConfigExporter.SetSceneNext(Camera2ConfigExporter.currentlyScenesSelected);
            }
            if (GUI.Button(new Rect(menuPos.x + 30, menuPos.y + 80, 230, 60), new GUIContent("Currently Selected:\n" + Camera2ConfigExporter.currentlyScenesSelected)))
            {
                Camera2ConfigExporter.SetSceneNext(Camera2ConfigExporter.currentlyScenesSelected);
            }

            GUI.Box(new Rect(menuPos.x, menuPos.y + 150, 300, 120), "Select profile Export to Scene in Camera2");
            if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 175, 140, 25), new GUIContent("<")))
            {
                CameraUtilities.TrySetLast(CameraUtilities.currentlySelected);
            }
            if (GUI.Button(new Rect(menuPos.x + 155, menuPos.y + 175, 140, 25), new GUIContent(">")))
            {
                CameraUtilities.SetNext(CameraUtilities.currentlySelected);
            }
            if (GUI.Button(new Rect(menuPos.x + 30, menuPos.y + 205, 230, 60), new GUIContent("Currently Selected:\n" + CameraUtilities.currentlySelected)))
            {
                CameraUtilities.SetNext(CameraUtilities.currentlySelected);
            }

            if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 280, 295, 25), new GUIContent("Export to Selected Scene")))
            {
                Camera2ConfigExporter.ExportCamera2Scene();
            }

            if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 310, 295, 25), new GUIContent("Import to New Profile")))
            {
                Camera2ConfigExporter.LoadCamera2Scene();
            }

            //if (GUI.Button(new Rect(menuPos.x + 10, menuPos.y + 360, 280, 40), new GUIContent("Import Setting\nLIV externalcamera.cfg")))

            if (GUI.Button(new Rect(menuPos.x, menuPos.y + 430, 300, 30), new GUIContent("Close Setting Convert Menu")))
            {
                contextMenu.MenuMode = ContextMenu.MenuState.MenuTop;
            }
        }
Ejemplo n.º 2
0
        void OnGUI()
        {
            if (showMenu)
            {
                Vector3 scale;
                float   originalWidth  = 1600f;
                float   originalHeight = 900f;

                scale.x = Screen.width / originalWidth;
                scale.y = Screen.height / originalHeight;
                scale.z = 1;
                Matrix4x4 originalMatrix = GUI.matrix;
                GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, scale);
                //Layer boxes for Opacity
                GUI.Box(new Rect(menuPos.x - 5, menuPos.y, 310, 470), $"CameraPlus {parentBehaviour.name}");
                GUI.Box(new Rect(menuPos.x - 5, menuPos.y, 310, 470), $"CameraPlus {parentBehaviour.name}");
                GUI.Box(new Rect(menuPos.x - 5, menuPos.y, 310, 470), $"CameraPlus {parentBehaviour.name}");

                CustomEnableStyle = new GUIStyle(GUI.skin.button);
                CustomEnableStyle.normal.background = CustomEnableStyle.active.background;
                CustomEnableStyle.hover.background  = CustomEnableStyle.active.background;
                CustomDisableStyle     = new GUIStyle(GUI.skin.button);
                ProfileStyle           = new GUIStyle(GUI.skin.box);
                ProfileStyle.alignment = UnityEngine.TextAnchor.MiddleLeft;

                if (MenuMode == MenuState.MenuTop)
                {
                    if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 25, 30, 30), texture))
                    {
                        parentBehaviour.Config.cameraLock.lockScreen = !parentBehaviour.Config.cameraLock.lockScreen;
                        parentBehaviour.Config.Save();
                        if (this.parentBehaviour.Config.cameraLock.lockScreen)
                        {
                            texture = CustomUtils.LoadTextureFromResources("CameraPlus.Resources.Lock.png");
                        }
                        else
                        {
                            texture = CustomUtils.LoadTextureFromResources("CameraPlus.Resources.UnLock.png");
                        }
                    }
                    GUI.Box(new Rect(menuPos.x + 35, menuPos.y + 25, 115, 30), new GUIContent(parentBehaviour.Config.cameraLock.lockScreen ? "Locked Screen" : "Unlocked Screen"), ProfileStyle);

                    if (GUI.Button(new Rect(menuPos.x + 150, menuPos.y + 25, 30, 30), Cameratexture))
                    {
                        if (!parentBehaviour.Config.cameraLock.lockCamera && !parentBehaviour.Config.cameraLock.dontSaveDrag)
                        {
                            parentBehaviour.Config.cameraLock.lockCamera   = true;
                            parentBehaviour.Config.cameraLock.dontSaveDrag = false;
                            Cameratexture = CustomUtils.LoadTextureFromResources("CameraPlus.Resources.CameraLock.png");
                        }
                        else if (parentBehaviour.Config.cameraLock.lockCamera && !parentBehaviour.Config.cameraLock.dontSaveDrag)
                        {
                            parentBehaviour.Config.cameraLock.lockCamera   = false;
                            parentBehaviour.Config.cameraLock.dontSaveDrag = true;
                            Cameratexture = CustomUtils.LoadTextureFromResources("CameraPlus.Resources.CameraLock.png");
                        }
                        else
                        {
                            parentBehaviour.Config.cameraLock.lockCamera   = false;
                            parentBehaviour.Config.cameraLock.dontSaveDrag = false;
                            Cameratexture = CustomUtils.LoadTextureFromResources("CameraPlus.Resources.CameraUnlock.png");
                        }
                        parentBehaviour.Config.Save();
                    }
                    GUI.Box(new Rect(menuPos.x + 185, menuPos.y + 25, 115, 30), new GUIContent(parentBehaviour.Config.cameraLock.dontSaveDrag ? "ResetDrag Camera" : (parentBehaviour.Config.cameraLock.lockCamera ? "Locked Camera" : "Unlocked Camera")), ProfileStyle);

                    if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 60, 145, 60), new GUIContent("Add New Camera")))
                    {
                        lock (Plugin.cameraController.Cameras)
                        {
                            string cameraName = CameraUtilities.GetNextCameraName();
                            Logger.log.Notice($"Adding new config with name {cameraName}.json");
                            CameraUtilities.AddNewCamera(cameraName);
                            CameraUtilities.ReloadCameras();
                            parentBehaviour.CloseContextMenu();
                        }
                    }
                    if (GUI.Button(new Rect(menuPos.x + 150, menuPos.y + 60, 145, 60), new GUIContent("Duplicate\nSelected Camera")))
                    {
                        lock (Plugin.cameraController.Cameras)
                        {
                            string cameraName = CameraUtilities.GetNextCameraName();
                            Logger.log.Notice($"Adding {cameraName}");
                            CameraUtilities.AddNewCamera(cameraName, parentBehaviour.Config);
                            CameraUtilities.ReloadCameras();
                            parentBehaviour.CloseContextMenu();
                        }
                    }
                    if (GUI.Button(new Rect(menuPos.x + 150, menuPos.y + 130, 145, 50), new GUIContent("Remove\nSelected Camera")))
                    {
                        lock (Plugin.cameraController.Cameras)
                        {
                            if (CameraUtilities.RemoveCamera(parentBehaviour))
                            {
                                parentBehaviour._isCameraDestroyed = true;
                                parentBehaviour.CreateScreenRenderTexture();
                                parentBehaviour.CloseContextMenu();
                                Logger.log.Notice("Camera removed!");
                            }
                        }
                    }

                    //First Person, Third Person, 360degree
                    GUI.Box(new Rect(menuPos.x, menuPos.y + 190, 300, 55), "Camera Mode");
                    if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 210, 95, 30), new GUIContent("First Person"), !parentBehaviour.Config.thirdPerson ? CustomEnableStyle : CustomDisableStyle))
                    {
                        parentBehaviour.Config.thirdPerson = false;
                        parentBehaviour.Config.cameraExtensions.follow360map = false;
                        parentBehaviour.ThirdPerson    = parentBehaviour.Config.thirdPerson;
                        parentBehaviour.ThirdPersonPos = parentBehaviour.Config.Position;
                        parentBehaviour.ThirdPersonRot = parentBehaviour.Config.Rotation;

                        parentBehaviour.CreateScreenRenderTexture();
                        parentBehaviour.Config.Save();
                    }
                    if (GUI.Button(new Rect(menuPos.x + 105, menuPos.y + 210, 95, 30), new GUIContent("Third Person"), (parentBehaviour.Config.thirdPerson && !parentBehaviour.Config.cameraExtensions.follow360map) ? CustomEnableStyle : CustomDisableStyle))
                    {
                        parentBehaviour.Config.thirdPerson = true;
                        parentBehaviour.Config.cameraExtensions.follow360map = false;
                        parentBehaviour.ThirdPersonPos = parentBehaviour.Config.Position;
                        parentBehaviour.ThirdPersonRot = parentBehaviour.Config.Rotation;

                        parentBehaviour.CreateScreenRenderTexture();
                        parentBehaviour.Config.Save();
                    }
                    if (GUI.Button(new Rect(menuPos.x + 205, menuPos.y + 210, 95, 30), new GUIContent("360 degree"), (parentBehaviour.Config.thirdPerson && parentBehaviour.Config.cameraExtensions.follow360map) ? CustomEnableStyle : CustomDisableStyle))
                    {
                        parentBehaviour.Config.thirdPerson = true;
                        parentBehaviour.Config.cameraExtensions.follow360map = true;
                        parentBehaviour.ThirdPersonPos = parentBehaviour.Config.Position;
                        parentBehaviour.ThirdPersonRot = parentBehaviour.Config.Rotation;

                        parentBehaviour.CreateScreenRenderTexture();
                        parentBehaviour.Config.Save();
                    }

                    if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 250, 145, 40), new GUIContent("Display Object")))
                    {
                        MenuMode = MenuState.DisplayObject;
                    }
                    if (GUI.Button(new Rect(menuPos.x + 150, menuPos.y + 250, 145, 40), new GUIContent("Layout")))
                    {
                        MenuMode = MenuState.Layout;
                    }
                    if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 295, 145, 40), new GUIContent("Multiplayer")))
                    {
                        MenuMode = MenuState.Multiplayer;
                    }
                    if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 340, 145, 40), new GUIContent("Profile Saver")))
                    {
                        MenuMode = MenuState.Profile;
                    }
                    if (GUI.Button(new Rect(menuPos.x + 150, menuPos.y + 340, 145, 40), new GUIContent("MovementScript")))
                    {
                        MenuMode   = MenuState.MovementScript;
                        scriptName = CameraUtilities.MovementScriptList();
                    }
                    if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 385, 145, 40), new GUIContent("Setting Converter")))
                    {
                        MenuMode = MenuState.SettingConverter;
                        Camera2ConfigExporter.Init();
                    }
                    if (GUI.Button(new Rect(menuPos.x + 150, menuPos.y + 385, 145, 40), new GUIContent("External linkage")))
                    {
                        MenuMode = MenuState.ExternalLink;
                    }

                    /*
                     * if (GUI.Button(new Rect(menuPos.x, menuPos.y + 345, 300, 30), new GUIContent(parentBehaviour.Config.Orthographics ? "Perspective" : "Orthographics")))
                     * {
                     *  parentBehaviour.Config.Orthographics = !parentBehaviour.Config.Orthographics;
                     *  parentBehaviour.Config.Save();
                     *  parentBehaviour.CloseContextMenu();
                     *  parentBehaviour.CreateScreenRenderTexture();
                     * }
                     */
                    /*
                     * if (GUI.Button(new Rect(menuPos.x, menuPos.y + 385, 300, 30), new GUIContent("Spawn 38 Cameras")))
                     * {
                     *  parentBehaviour.StartCoroutine(CameraUtilities.Spawn38Cameras());
                     *  parentBehaviour.CloseContextMenu();
                     * }*/
                    if (GUI.Button(new Rect(menuPos.x, menuPos.y + 430, 300, 30), new GUIContent("Close Menu")))
                    {
                        parentBehaviour.CloseContextMenu();
                    }
                }
                else if (MenuMode == MenuState.DisplayObject)
                {
                    _menuDisplayObject.DiplayMenu(parentBehaviour, this, menuPos);
                }
                else if (MenuMode == MenuState.Layout)
                {
                    _menuLayout.DiplayMenu(parentBehaviour, this, menuPos);
                }
                else if (MenuMode == MenuState.Multiplayer)
                {
                    _menuMultiplayer.DiplayMenu(parentBehaviour, this, menuPos);
                }
                else if (MenuMode == MenuState.Profile)
                {
                    _menuProfile.DiplayMenu(parentBehaviour, this, menuPos);
                }
                else if (MenuMode == MenuState.MovementScript)
                {
                    _menuMovementScript.DiplayMenu(parentBehaviour, this, menuPos);
                }
                else if (MenuMode == MenuState.SettingConverter)
                {
                    _menuSettingConverter.DiplayMenu(parentBehaviour, this, menuPos);
                }
                else if (MenuMode == MenuState.ExternalLink)
                {
                    _menuExternalLink.DiplayMenu(parentBehaviour, this, menuPos);
                }
                else if (MenuMode == MenuState.ChromaKey)
                {
                    _menuChromakey.DiplayMenu(parentBehaviour, this, menuPos);
                }
                GUI.matrix = originalMatrix;
            }
        }