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, 400), "CameraPlus"); GUI.Box(new Rect(menuPos.x - 5, menuPos.y, 310, 400), "CameraPlus"); GUI.Box(new Rect(menuPos.x - 5, menuPos.y, 310, 400), "CameraPlus"); if (verify38) { GUI.Box(new Rect(menuPos.x, menuPos.y + 35, 290, 70), "Are You Sure?"); if (GUI.Button(new Rect(menuPos.x, menuPos.y + 75, 140, 30), new GUIContent("Yes."))) { parentBehaviour.StartCoroutine(CameraUtilities.Spawn38Cameras()); verify38 = false; parentBehaviour.CloseContextMenu(); } if (GUI.Button(new Rect(menuPos.x + 155, menuPos.y + 75, 140, 30), new GUIContent("No."))) { verify38 = false; } } else if (!layoutMode) { if (GUI.Button(new Rect(menuPos.x, menuPos.y + 25, 120, 30), new GUIContent("Add New Camera"))) { lock (Plugin.Instance.Cameras) { string cameraName = CameraUtilities.GetNextCameraName(); Logger.Log($"Adding new config with name {cameraName}.cfg"); CameraUtilities.AddNewCamera(cameraName); CameraUtilities.ReloadCameras(); parentBehaviour.CloseContextMenu(); } } if (GUI.Button(new Rect(menuPos.x + 130, menuPos.y + 25, 170, 30), new GUIContent("Remove Selected Camera"))) { lock (Plugin.Instance.Cameras) { if (CameraUtilities.RemoveCamera(parentBehaviour)) { parentBehaviour._isCameraDestroyed = true; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.CloseContextMenu(); Logger.Log("Camera removed!", LogLevel.Notice); } } } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 65, 170, 30), new GUIContent("Duplicate Selected Camera"))) { lock (Plugin.Instance.Cameras) { string cameraName = CameraUtilities.GetNextCameraName(); Logger.Log($"Adding {cameraName}", LogLevel.Notice); CameraUtilities.AddNewCamera(cameraName, parentBehaviour.Config); CameraUtilities.ReloadCameras(); parentBehaviour.CloseContextMenu(); } } if (GUI.Button(new Rect(menuPos.x + 180, menuPos.y + 65, 120, 30), new GUIContent("Layout"))) { layoutMode = true; } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 105, 120, 30), new GUIContent(parentBehaviour.Config.thirdPerson ? " First Person" : "Third Person"))) { parentBehaviour.Config.thirdPerson = !parentBehaviour.Config.thirdPerson; parentBehaviour.ThirdPerson = parentBehaviour.Config.thirdPerson; parentBehaviour.ThirdPersonPos = parentBehaviour.Config.Position; parentBehaviour.ThirdPersonRot = parentBehaviour.Config.Rotation; //FirstPersonOffset = Config.FirstPersonPositionOffset; // FirstPersonRotationOffset = Config.FirstPersonRotationOffset; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.CloseContextMenu(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 130, menuPos.y + 105, 170, 30), new GUIContent(parentBehaviour.Config.showThirdPersonCamera ? "Hide Third Person Camera" : "Show Third Person Camera"))) { parentBehaviour.Config.showThirdPersonCamera = !parentBehaviour.Config.showThirdPersonCamera; parentBehaviour.Config.Save(); parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.CloseContextMenu(); } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 145, 170, 30), new GUIContent(parentBehaviour.Config.forceFirstPersonUpRight ? "Don't Force Camera Upright" : "Force Camera Upright"))) { parentBehaviour.Config.forceFirstPersonUpRight = !parentBehaviour.Config.forceFirstPersonUpRight; parentBehaviour.Config.Save(); parentBehaviour.CloseContextMenu(); } if (GUI.Button(new Rect(menuPos.x + 180, menuPos.y + 145, 120, 30), new GUIContent(parentBehaviour.Config.transparentWalls ? "Solid Walls" : "Transparent Walls"))) { parentBehaviour.Config.transparentWalls = !parentBehaviour.Config.transparentWalls; parentBehaviour.SetCullingMask(); parentBehaviour.CloseContextMenu(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 185, 300, 30), new GUIContent("Close Menu"))) { parentBehaviour.CloseContextMenu(); } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 355, 300, 30), new GUIContent("Spawn 38 Cameras"))) { verify38 = true; } } else { if (GUI.Button(new Rect(menuPos.x, menuPos.y + 25, 290, 30), new GUIContent("Reset Camera Position and Rotation"))) { parentBehaviour.Config.Position = parentBehaviour.Config.DefaultPosition; parentBehaviour.Config.Rotation = parentBehaviour.Config.DefaultRotation; parentBehaviour.Config.FirstPersonPositionOffset = parentBehaviour.Config.DefaultFirstPersonPositionOffset; parentBehaviour.Config.FirstPersonRotationOffset = parentBehaviour.Config.DefaultFirstPersonRotationOffset; parentBehaviour.ThirdPersonPos = parentBehaviour.Config.DefaultPosition; parentBehaviour.ThirdPersonRot = parentBehaviour.Config.DefaultRotation; parentBehaviour.Config.Save(); parentBehaviour.CloseContextMenu(); } //Layer GUI.Box(new Rect(menuPos.x, menuPos.y + 65, 290, 70), "Layer: " + parentBehaviour.Config.layer); if (GUI.Button(new Rect(menuPos.x, menuPos.y + 85, 140, 30), new GUIContent("-"))) { parentBehaviour.Config.layer--; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 155, menuPos.y + 85, 140, 30), new GUIContent("+"))) { parentBehaviour.Config.layer++; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } //FOV GUI.Box(new Rect(menuPos.x, menuPos.y + 125, 290, 70), "FOV: " + parentBehaviour.Config.fov); if (GUI.Button(new Rect(menuPos.x, menuPos.y + 145, 140, 30), new GUIContent("-"))) { parentBehaviour.Config.fov--; parentBehaviour.SetFOV(); parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 155, menuPos.y + 145, 140, 30), new GUIContent("+"))) { parentBehaviour.Config.fov++; parentBehaviour.SetFOV(); parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } //Render Scale GUI.Box(new Rect(menuPos.x, menuPos.y + 185, 290, 70), "Render Scale: " + parentBehaviour.Config.renderScale.ToString("F1")); if (GUI.Button(new Rect(menuPos.x, menuPos.y + 205, 140, 30), new GUIContent("-"))) { parentBehaviour.Config.renderScale -= 0.1f; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 155, menuPos.y + 205, 140, 30), new GUIContent("+"))) { parentBehaviour.Config.renderScale += 0.1f; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 255, 290, 30), new GUIContent(parentBehaviour.Config.fitToCanvas ? " Don't Fit To Canvas" : "Fit To Canvas"))) { parentBehaviour.Config.fitToCanvas = !parentBehaviour.Config.fitToCanvas; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 305, 290, 30), new GUIContent("Close Layout Menu"))) { layoutMode = false; } } GUI.matrix = originalMatrix; } }
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); if (!layoutMode && !profileMode) { if (GUI.Button(new Rect(menuPos.x, menuPos.y + 25, 120, 30), new GUIContent("Add New Camera"))) { lock (Plugin.Instance.Cameras) { string cameraName = CameraUtilities.GetNextCameraName(); Logger.Log($"Adding new config with name {cameraName}.cfg"); CameraUtilities.AddNewCamera(cameraName); CameraUtilities.ReloadCameras(); parentBehaviour.CloseContextMenu(); } } if (GUI.Button(new Rect(menuPos.x + 130, menuPos.y + 25, 170, 30), new GUIContent("Remove Selected Camera"))) { lock (Plugin.Instance.Cameras) { if (CameraUtilities.RemoveCamera(parentBehaviour)) { parentBehaviour._isCameraDestroyed = true; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.CloseContextMenu(); Logger.Log("Camera removed!", LogLevel.Notice); } } } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 65, 170, 30), new GUIContent("Duplicate Selected Camera"))) { lock (Plugin.Instance.Cameras) { string cameraName = CameraUtilities.GetNextCameraName(); Logger.Log($"Adding {cameraName}", LogLevel.Notice); CameraUtilities.AddNewCamera(cameraName, parentBehaviour.Config); CameraUtilities.ReloadCameras(); parentBehaviour.CloseContextMenu(); } } if (GUI.Button(new Rect(menuPos.x + 180, menuPos.y + 65, 120, 30), new GUIContent("Layout"))) { layoutMode = true; } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 105, 120, 30), new GUIContent(parentBehaviour.Config.use360Camera? "First Person" : parentBehaviour.Config.thirdPerson ? " 360 Third Person" : "Third Person"))) { if (parentBehaviour.Config.use360Camera) { parentBehaviour.Config.thirdPerson = !parentBehaviour.Config.thirdPerson; parentBehaviour.ThirdPerson = parentBehaviour.Config.thirdPerson; parentBehaviour.ThirdPersonPos = parentBehaviour.Config.Position; parentBehaviour.ThirdPersonRot = parentBehaviour.Config.Rotation; parentBehaviour.Config.use360Camera = false; } else if (parentBehaviour.Config.thirdPerson) { parentBehaviour.Config.use360Camera = true; } else { parentBehaviour.Config.thirdPerson = !parentBehaviour.Config.thirdPerson; parentBehaviour.ThirdPerson = parentBehaviour.Config.thirdPerson; parentBehaviour.ThirdPersonPos = parentBehaviour.Config.Position; parentBehaviour.ThirdPersonRot = parentBehaviour.Config.Rotation; } // FirstPersonOffset = Config.FirstPersonPositionOffset; // FirstPersonRotationOffset = Config.FirstPersonRotationOffset; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.CloseContextMenu(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 130, menuPos.y + 105, 170, 30), new GUIContent(parentBehaviour.Config.showThirdPersonCamera ? "Hide Third Person Camera" : "Show Third Person Camera"))) { parentBehaviour.Config.showThirdPersonCamera = !parentBehaviour.Config.showThirdPersonCamera; parentBehaviour.Config.Save(); parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.CloseContextMenu(); } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 145, 170, 30), new GUIContent(parentBehaviour.Config.forceFirstPersonUpRight ? "Don't Force Camera Upright" : "Force Camera Upright"))) { parentBehaviour.Config.forceFirstPersonUpRight = !parentBehaviour.Config.forceFirstPersonUpRight; parentBehaviour.Config.Save(); parentBehaviour.CloseContextMenu(); } if (GUI.Button(new Rect(menuPos.x + 180, menuPos.y + 145, 120, 30), new GUIContent(parentBehaviour.Config.transparentWalls ? "Solid Walls" : "Transparent Walls"))) { parentBehaviour.Config.transparentWalls = !parentBehaviour.Config.transparentWalls; parentBehaviour.SetCullingMask(); parentBehaviour.CloseContextMenu(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 185, 120, 30), new GUIContent(parentBehaviour.Config.avatar ? "Hide Avatar" : "Show Avatar"))) { parentBehaviour.Config.avatar = !parentBehaviour.Config.avatar; parentBehaviour.SetCullingMask(); parentBehaviour.CloseContextMenu(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 130, menuPos.y + 185, 170, 30), new GUIContent(parentBehaviour.Config.debris == "link" ? "Force Show Debris" : parentBehaviour.Config.debris == "show" ? "Force Hide Debris" : "Use Game Debris Settings"))) { if (parentBehaviour.Config.debris == "link") { parentBehaviour.Config.debris = "show"; } else if (parentBehaviour.Config.debris == "show") { parentBehaviour.Config.debris = "hide"; } else { parentBehaviour.Config.debris = "link"; } parentBehaviour.SetCullingMask(); parentBehaviour.CloseContextMenu(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 225, 120, 30), new GUIContent(parentBehaviour.Config.displayUI ? "Show UI" : "Hide UI"))) { parentBehaviour.Config.displayUI = !parentBehaviour.Config.displayUI; parentBehaviour.SetCullingMask(); parentBehaviour.CloseContextMenu(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 130, menuPos.y + 225, 170, 30), new GUIContent(parentBehaviour.Config.movementAudioSync ? "ScriptSyncUnity" : "ScriptSyncAudio"))) { parentBehaviour.Config.movementAudioSync = !parentBehaviour.Config.movementAudioSync; parentBehaviour.SetCullingMask(); parentBehaviour.CloseContextMenu(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 265, 300, 30), new GUIContent("Profile Saver"))) { profileMode = true; } 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 (layoutMode) { if (GUI.Button(new Rect(menuPos.x, menuPos.y + 25, 290, 30), new GUIContent("Reset Camera Position and Rotation"))) { parentBehaviour.Config.Position = parentBehaviour.Config.DefaultPosition; parentBehaviour.Config.Rotation = parentBehaviour.Config.DefaultRotation; parentBehaviour.Config.FirstPersonPositionOffset = parentBehaviour.Config.DefaultFirstPersonPositionOffset; parentBehaviour.Config.FirstPersonRotationOffset = parentBehaviour.Config.DefaultFirstPersonRotationOffset; parentBehaviour.ThirdPersonPos = parentBehaviour.Config.DefaultPosition; parentBehaviour.ThirdPersonRot = parentBehaviour.Config.DefaultRotation; parentBehaviour.Config.Save(); parentBehaviour.CloseContextMenu(); } //Layer GUI.Box(new Rect(menuPos.x, menuPos.y + 60, 140, 55), "Layer: " + parentBehaviour.Config.layer); if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 80, 60, 30), new GUIContent("-"))) { parentBehaviour.Config.layer--; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 75, menuPos.y + 80, 60, 30), new GUIContent("+"))) { parentBehaviour.Config.layer++; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } //FOV GUI.Box(new Rect(menuPos.x + 155, menuPos.y + 60, 140, 55), "FOV: " + parentBehaviour.Config.fov); if (GUI.Button(new Rect(menuPos.x + 160, menuPos.y + 80, 60, 30), new GUIContent("-"))) { parentBehaviour.Config.fov--; parentBehaviour.SetFOV(); parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 230, menuPos.y + 80, 60, 30), new GUIContent("+"))) { parentBehaviour.Config.fov++; parentBehaviour.SetFOV(); parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } //Render Scale GUI.Box(new Rect(menuPos.x, menuPos.y + 120, 140, 55), "Render Scale: " + parentBehaviour.Config.renderScale.ToString("F1")); if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 140, 60, 30), new GUIContent("-"))) { parentBehaviour.Config.renderScale -= 0.1f; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 75, menuPos.y + 140, 60, 30), new GUIContent("+"))) { parentBehaviour.Config.renderScale += 0.1f; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } //Fit Canvas if (GUI.Button(new Rect(menuPos.x + 155, menuPos.y + 140, 140, 30), new GUIContent(parentBehaviour.Config.fitToCanvas ? " Don't Fit To Canvas" : "Fit To Canvas"))) { parentBehaviour.Config.fitToCanvas = !parentBehaviour.Config.fitToCanvas; parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } //Amount of Movemnet GUI.Box(new Rect(menuPos.x, menuPos.y + 180, 210, 55), "Amount movement : " + amountMove.ToString("F2")); if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 200, 60, 30), new GUIContent("0.01"))) { amountMove = 0.01f; parentBehaviour.CreateScreenRenderTexture(); } if (GUI.Button(new Rect(menuPos.x + 75, menuPos.y + 200, 60, 30), new GUIContent("0.10"))) { amountMove = 0.1f; parentBehaviour.CreateScreenRenderTexture(); } if (GUI.Button(new Rect(menuPos.x + 145, menuPos.y + 200, 60, 30), new GUIContent("1.00"))) { amountMove = 1.0f; parentBehaviour.CreateScreenRenderTexture(); } //X Position GUI.Box(new Rect(menuPos.x, menuPos.y + 240, 95, 55), "X Pos :" + (parentBehaviour.Config.use360Camera ? parentBehaviour.Config.cam360RightOffset.ToString("F2") : (parentBehaviour.Config.thirdPerson ? parentBehaviour.Config.posx.ToString("F2") : parentBehaviour.Config.firstPersonPosOffsetX.ToString("F2")))); if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 260, 40, 30), new GUIContent("-"))) { if (parentBehaviour.Config.use360Camera) { parentBehaviour.Config.cam360RightOffset -= amountMove; } else if (parentBehaviour.Config.thirdPerson) { parentBehaviour.Config.posx -= amountMove; } else { parentBehaviour.Config.firstPersonPosOffsetX -= amountMove; } parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 50, menuPos.y + 260, 40, 30), new GUIContent("+"))) { if (parentBehaviour.Config.use360Camera) { parentBehaviour.Config.cam360RightOffset += amountMove; } else if (parentBehaviour.Config.thirdPerson) { parentBehaviour.Config.posx += amountMove; } else { parentBehaviour.Config.firstPersonPosOffsetX += amountMove; } parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } //Y Position GUI.Box(new Rect(menuPos.x + 100, menuPos.y + 240, 95, 55), "Y Pos :" + (parentBehaviour.Config.use360Camera ? parentBehaviour.Config.cam360UpOffset.ToString("F2") : (parentBehaviour.Config.thirdPerson ? parentBehaviour.Config.posy.ToString("F2") : parentBehaviour.Config.firstPersonPosOffsetY.ToString("F2")))); if (GUI.Button(new Rect(menuPos.x + 105, menuPos.y + 260, 40, 30), new GUIContent("-"))) { if (parentBehaviour.Config.use360Camera) { parentBehaviour.Config.cam360UpOffset -= amountMove; } else if (parentBehaviour.Config.thirdPerson) { parentBehaviour.Config.posy -= amountMove; } else { parentBehaviour.Config.firstPersonPosOffsetY -= amountMove; } parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 150, menuPos.y + 260, 40, 30), new GUIContent("+"))) { if (parentBehaviour.Config.use360Camera) { parentBehaviour.Config.cam360UpOffset += amountMove; } else if (parentBehaviour.Config.thirdPerson) { parentBehaviour.Config.posy += amountMove; } else { parentBehaviour.Config.firstPersonPosOffsetY += amountMove; } parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } //Z Position GUI.Box(new Rect(menuPos.x + 205, menuPos.y + 240, 95, 55), "Z Pos :" + (parentBehaviour.Config.use360Camera ? parentBehaviour.Config.cam360ForwardOffset.ToString("F2") : (parentBehaviour.Config.thirdPerson ? parentBehaviour.Config.posz.ToString("F2") : parentBehaviour.Config.firstPersonPosOffsetZ.ToString("F2")))); if (GUI.Button(new Rect(menuPos.x + 210, menuPos.y + 260, 40, 30), new GUIContent("-"))) { if (parentBehaviour.Config.use360Camera) { parentBehaviour.Config.cam360ForwardOffset -= amountMove; } else if (parentBehaviour.Config.thirdPerson) { parentBehaviour.Config.posz -= amountMove; } else { parentBehaviour.Config.firstPersonPosOffsetZ -= amountMove; } parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 255, menuPos.y + 260, 40, 30), new GUIContent("+"))) { if (parentBehaviour.Config.use360Camera) { parentBehaviour.Config.cam360ForwardOffset += amountMove; } else if (parentBehaviour.Config.thirdPerson) { parentBehaviour.Config.posz += amountMove; } else { parentBehaviour.Config.firstPersonPosOffsetZ += amountMove; } parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } //Amount of Rotation GUI.Box(new Rect(menuPos.x, menuPos.y + 300, 290, 55), "Amount rotation : " + amountRot.ToString("F2")); if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 320, 50, 30), new GUIContent("0.01"))) { amountRot = 0.01f; parentBehaviour.CreateScreenRenderTexture(); } if (GUI.Button(new Rect(menuPos.x + 60, menuPos.y + 320, 50, 30), new GUIContent("0.10"))) { amountRot = 0.1f; parentBehaviour.CreateScreenRenderTexture(); } if (GUI.Button(new Rect(menuPos.x + 115, menuPos.y + 320, 50, 30), new GUIContent("1.00"))) { amountRot = 1.0f; parentBehaviour.CreateScreenRenderTexture(); } if (GUI.Button(new Rect(menuPos.x + 170, menuPos.y + 320, 50, 30), new GUIContent("10"))) { amountRot = 10.0f; parentBehaviour.CreateScreenRenderTexture(); } if (GUI.Button(new Rect(menuPos.x + 225, menuPos.y + 320, 50, 30), new GUIContent("45"))) { amountRot = 45.0f; parentBehaviour.CreateScreenRenderTexture(); } //X Rotation GUI.Box(new Rect(menuPos.x, menuPos.y + 360, 95, 55), "X Rot :" + (parentBehaviour.Config.use360Camera ? parentBehaviour.Config.cam360XTilt.ToString("F2") : (parentBehaviour.Config.thirdPerson ? parentBehaviour.Config.angx.ToString("F2") : parentBehaviour.Config.firstPersonRotOffsetX.ToString("F2")))); if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 380, 40, 30), new GUIContent("-"))) { if (parentBehaviour.Config.use360Camera) { parentBehaviour.Config.cam360XTilt -= amountRot; } else if (parentBehaviour.Config.thirdPerson) { parentBehaviour.Config.angx -= amountRot; } else { parentBehaviour.Config.firstPersonRotOffsetX -= amountRot; } parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 50, menuPos.y + 380, 40, 30), new GUIContent("+"))) { if (parentBehaviour.Config.use360Camera) { parentBehaviour.Config.cam360XTilt += amountRot; } else if (parentBehaviour.Config.thirdPerson) { parentBehaviour.Config.angx += amountRot; } else { parentBehaviour.Config.firstPersonRotOffsetX += amountRot; } parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } //Y Rotation GUI.Box(new Rect(menuPos.x + 100, menuPos.y + 360, 95, 55), "Y Rot :" + (parentBehaviour.Config.use360Camera ? parentBehaviour.Config.cam360YTilt.ToString("F2") : (parentBehaviour.Config.thirdPerson ? parentBehaviour.Config.angy.ToString("F2") : parentBehaviour.Config.firstPersonRotOffsetY.ToString("F2")))); if (GUI.Button(new Rect(menuPos.x + 105, menuPos.y + 380, 40, 30), new GUIContent("-"))) { if (parentBehaviour.Config.use360Camera) { parentBehaviour.Config.cam360YTilt -= amountRot; } else if (parentBehaviour.Config.thirdPerson) { parentBehaviour.Config.angy -= amountRot; } else { parentBehaviour.Config.firstPersonRotOffsetY -= amountRot; } parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 150, menuPos.y + 380, 40, 30), new GUIContent("+"))) { if (parentBehaviour.Config.use360Camera) { parentBehaviour.Config.cam360YTilt += amountRot; } else if (parentBehaviour.Config.thirdPerson) { parentBehaviour.Config.angy += amountRot; } else { parentBehaviour.Config.firstPersonRotOffsetY += amountRot; } parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } //Z Rotation GUI.Box(new Rect(menuPos.x + 205, menuPos.y + 360, 95, 55), "Z Rot :" + (parentBehaviour.Config.use360Camera ? parentBehaviour.Config.cam360ZTilt.ToString("F2") : (parentBehaviour.Config.thirdPerson ? parentBehaviour.Config.angz.ToString("F2") : parentBehaviour.Config.firstPersonRotOffsetZ.ToString("F2")))); if (GUI.Button(new Rect(menuPos.x + 210, menuPos.y + 380, 40, 30), new GUIContent("-"))) { if (parentBehaviour.Config.use360Camera) { parentBehaviour.Config.cam360ZTilt -= amountRot; } else if (parentBehaviour.Config.thirdPerson) { parentBehaviour.Config.angz -= amountRot; } else { parentBehaviour.Config.firstPersonRotOffsetZ -= amountRot; } parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } if (GUI.Button(new Rect(menuPos.x + 255, menuPos.y + 380, 40, 30), new GUIContent("+"))) { if (parentBehaviour.Config.use360Camera) { parentBehaviour.Config.cam360ZTilt += amountRot; } else if (parentBehaviour.Config.thirdPerson) { parentBehaviour.Config.angz += amountRot; } else { parentBehaviour.Config.firstPersonRotOffsetZ += amountRot; } parentBehaviour.CreateScreenRenderTexture(); parentBehaviour.Config.Save(); } //Close if (GUI.Button(new Rect(menuPos.x, menuPos.y + 430, 290, 30), new GUIContent("Close Layout Menu"))) { layoutMode = false; } } else if (profileMode) { if (GUI.Button(new Rect(menuPos.x, menuPos.y + 25, 140, 30), new GUIContent("<"))) { CameraProfiles.TrySetLast(CameraProfiles.currentlySelected); } if (GUI.Button(new Rect(menuPos.x + 155, menuPos.y + 25, 140, 30), new GUIContent(">"))) { CameraProfiles.SetNext(CameraProfiles.currentlySelected); } if (GUI.Button(new Rect(menuPos.x + 30, menuPos.y + 65, 230, 80), new GUIContent("Currently Selected:\n" + CameraProfiles.currentlySelected))) { CameraProfiles.SetNext(CameraProfiles.currentlySelected); } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 155, 140, 30), new GUIContent("Save"))) { CameraProfiles.SaveCurrent(); } if (GUI.Button(new Rect(menuPos.x + 150, menuPos.y + 155, 140, 30), new GUIContent("Delete"))) { CameraProfiles.DeleteProfile(CameraProfiles.currentlySelected); } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 195, 290, 30), new GUIContent("Load Selected"))) { var cs = Resources.FindObjectsOfTypeAll <CameraPlusBehaviour>(); foreach (var c in cs) { CameraUtilities.RemoveCamera(c); } foreach (var csi in Plugin.Instance.Cameras.Values) { Destroy(csi.Instance.gameObject); } Plugin.Instance.Cameras.Clear(); CameraProfiles.SetProfile(CameraProfiles.currentlySelected); CameraUtilities.ReloadCameras(); } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 245, 290, 30), new GUIContent(Plugin.Instance._rootConfig.ProfileSceneChange ? "To SceneChange Off" : "To SceneChange On"))) { Plugin.Instance._rootConfig.ProfileSceneChange = !Plugin.Instance._rootConfig.ProfileSceneChange; Plugin.Instance._rootConfig.Save(); } if (Plugin.Instance._rootConfig.ProfileSceneChange) { GUI.Box(new Rect(menuPos.x, menuPos.y + 285, 290, 30), "Menu Scene Profile : " + (Plugin.Instance._rootConfig.MenuProfile)); GUI.Box(new Rect(menuPos.x, menuPos.y + 315, 290, 30), "Game Scene Profile : " + (Plugin.Instance._rootConfig.GameProfile)); if (GUI.Button(new Rect(menuPos.x, menuPos.y + 345, 140, 30), new GUIContent("Set Menu Selected"))) { Plugin.Instance._rootConfig.MenuProfile = CameraProfiles.currentlySelected; } if (GUI.Button(new Rect(menuPos.x + 150, menuPos.y + 345, 140, 30), new GUIContent("Set Game Selected"))) { Plugin.Instance._rootConfig.GameProfile = CameraProfiles.currentlySelected; } } if (GUI.Button(new Rect(menuPos.x, menuPos.y + 430, 290, 30), new GUIContent("Close Profile Menu"))) { profileMode = false; } } GUI.matrix = originalMatrix; } }
void DisplayContextMenu() { _menuStrip = new ContextMenuStrip(); // Adds a new camera into the scene _menuStrip.Items.Add("Add New Camera", null, (p1, p2) => { lock (Plugin.Instance.Cameras) { string cameraName = CameraUtilities.GetNextCameraName(); Plugin.Log($"Adding new config with name {cameraName}.cfg"); CameraUtilities.AddNewCamera(cameraName); CameraUtilities.ReloadCameras(); CloseContextMenu(); } }); // Instantiates an exact copy of the currently selected camera _menuStrip.Items.Add("Duplicate Selected Camera", null, (p1, p2) => { lock (Plugin.Instance.Cameras) { string cameraName = CameraUtilities.GetNextCameraName(); Plugin.Log($"Adding {cameraName}"); CameraUtilities.AddNewCamera(cameraName, Config); CameraUtilities.ReloadCameras(); CloseContextMenu(); } }); // Removes the selected camera from the scene, and deletes the config associated with it _menuStrip.Items.Add("Remove Selected Camera", null, (p1, p2) => { lock (Plugin.Instance.Cameras) { if (CameraUtilities.RemoveCamera(this)) { _isCameraDestroyed = true; CreateScreenRenderTexture(); CloseContextMenu(); Plugin.Log("Camera removed!"); } else { MessageBox.Show("Cannot remove main camera!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }); _menuStrip.Items.Add(new ToolStripSeparator()); // Toggles between third/first person _menuStrip.Items.Add(Config.thirdPerson ? "First Person" : "Third Person", null, (p1, p2) => { Config.thirdPerson = !Config.thirdPerson; ThirdPerson = Config.thirdPerson; ThirdPersonPos = Config.Position; ThirdPersonRot = Config.Rotation; FirstPersonOffset = Config.FirstPersonPositionOffset; CreateScreenRenderTexture(); CloseContextMenu(); Config.Save(); }); if (Config.thirdPerson) { // Hides/unhides the third person camera that appears when a camera is in third person mode _menuStrip.Items.Add(Config.showThirdPersonCamera ? "Hide Third Person Camera" : "Show Third Person Camera", null, (p1, p2) => { Config.showThirdPersonCamera = !Config.showThirdPersonCamera; Config.Save(); CreateScreenRenderTexture(); CloseContextMenu(); }); // Hides/unhides the third person camera that appears when a camera is in third person mode _menuStrip.Items.Add("Reset Camera Position/Rotation", null, (p1, p2) => { Config.Position = Config.DefaultPosition; Config.Rotation = Config.DefaultRotation; Config.FirstPersonPositionOffset = Config.DefaultFirstPersonPositionOffset; ThirdPersonPos = Config.DefaultPosition; ThirdPersonRot = Config.DefaultRotation; FirstPersonOffset = Config.FirstPersonPositionOffset; Config.Save(); CloseContextMenu(); }); _menuStrip.Items.Add(Config.droneCam ? "Disable DroneCam" : "Ënable Drone Cam", null, (p1, p2) => { if (Config.droneCam && droneCam != null) { Config.droneCam = false; droneCam.CleanUp(); Destroy(droneCam); } else { Config.droneCam = true; droneCam = gameObject.AddComponent <DroneCam.DroneCam>(); droneCam.SetupCam(Path.GetFileName(Config.FilePath)); } Config.droneCam = false; Config.Save(); }); } _menuStrip.Items.Add(new ToolStripSeparator()); // Toggle transparent walls _menuStrip.Items.Add(Config.transparentWalls ? "Solid Walls" : "Transparent Walls", null, (p1, p2) => { Config.transparentWalls = !Config.transparentWalls; SetCullingMask(); CloseContextMenu(); Config.Save(); }); _menuStrip.Items.Add(new ToolStripSeparator()); var _layoutMenu = new ToolStripMenuItem("Layout"); _controlTracker.Add(_layoutMenu); // Sets the layer associated with the current camera _layoutMenu.DropDownItems.Add(new ToolStripLabel("Layer")); var _layerBox = new ToolStripNumberControl(); _controlTracker.Add(_layerBox); _layerBox.Maximum = int.MaxValue; _layerBox.Minimum = int.MinValue; _layerBox.Value = Config.layer; _layerBox.ValueChanged += (sender, args) => { Config.layer = (int)_layerBox.Value; CreateScreenRenderTexture(); Config.Save(); }; _layoutMenu.DropDownItems.Add(_layerBox); // FOV _layoutMenu.DropDownItems.Add(new ToolStripLabel("FOV")); var _fov = new ToolStripNumberControl(); _controlTracker.Add(_fov); _fov.Maximum = 179; _fov.Minimum = 0; _fov.Value = (decimal)Config.fov; _fov.ValueChanged += (sender, args) => { Config.fov = (int)_fov.Value; SetFOV(); CreateScreenRenderTexture(); Config.Save(); }; _layoutMenu.DropDownItems.Add(_fov); // Render Scale _layoutMenu.DropDownItems.Add(new ToolStripLabel("Render Scale")); var _renderScale = new ToolStripNumberControl(); _controlTracker.Add(_renderScale); _renderScale.Maximum = 4; _renderScale.Minimum = 0.1M; _renderScale.Increment = 0.1M; _renderScale.DecimalPlaces = 1; _renderScale.Value = (decimal)Config.renderScale; _renderScale.ValueChanged += (sender, args) => { Config.renderScale = (float)_renderScale.Value; CreateScreenRenderTexture(); Config.Save(); }; _layoutMenu.DropDownItems.Add(_renderScale); // Sets the size of the current cameras pixelrect _layoutMenu.DropDownItems.Add(new ToolStripLabel("Size")); var _widthBox = new ToolStripNumberControl(); _controlTracker.Add(_widthBox); _widthBox.Maximum = Screen.width; _widthBox.Minimum = 0; _widthBox.Value = Config.screenWidth; _widthBox.ValueChanged += (sender, args) => { Config.screenWidth = (int)_widthBox.Value; GL.Clear(false, true, Color.black, 0); CreateScreenRenderTexture(); Config.Save(); }; _layoutMenu.DropDownItems.Add(_widthBox); var _heightBox = new ToolStripNumberControl(); _controlTracker.Add(_heightBox); _heightBox.Maximum = Screen.height; _heightBox.Minimum = 0; _heightBox.Value = Config.screenHeight; _heightBox.ValueChanged += (sender, args) => { Config.screenHeight = (int)_heightBox.Value; GL.Clear(false, true, Color.black, 0); CreateScreenRenderTexture(); Config.Save(); }; _layoutMenu.DropDownItems.Add(_heightBox); // Set the location of the current cameras pixelrect _layoutMenu.DropDownItems.Add(new ToolStripLabel("Position")); var _xBox = new ToolStripNumberControl(); _controlTracker.Add(_xBox); _xBox.Maximum = Screen.width; _xBox.Minimum = 0; _xBox.Value = Config.screenPosX; _xBox.ValueChanged += (sender, args) => { Config.screenPosX = (int)_xBox.Value; CreateScreenRenderTexture(); Config.Save(); }; _layoutMenu.DropDownItems.Add(_xBox); var _yBox = new ToolStripNumberControl(); _controlTracker.Add(_yBox); _yBox.Maximum = Screen.height; _yBox.Minimum = 0; _yBox.Value = Config.screenPosY; _yBox.ValueChanged += (sender, args) => { Config.screenPosY = (int)_yBox.Value; CreateScreenRenderTexture(); Config.Save(); }; _layoutMenu.DropDownItems.Add(_yBox); // Fit to canvas checkbox var _fitToCanvasBox = new ToolStripCheckBox("Fit to Canvas"); _controlTracker.Add(_fitToCanvasBox); _fitToCanvasBox.Checked = Config.fitToCanvas; _fitToCanvasBox.CheckedChanged += (sender, args) => { Config.fitToCanvas = _fitToCanvasBox.Checked; _widthBox.Enabled = !Config.fitToCanvas; _heightBox.Enabled = !Config.fitToCanvas; _xBox.Enabled = !Config.fitToCanvas; _yBox.Enabled = !Config.fitToCanvas; CreateScreenRenderTexture(); Config.Save(); }; _layoutMenu.DropDownItems.Add(_fitToCanvasBox); // Finally, add our layout menu to the main menustrip _menuStrip.Items.Add(_layoutMenu); // Set the initial state for our width/height boxes depending on whether or not fitToCanvas is enabled _widthBox.Enabled = !Config.fitToCanvas; _heightBox.Enabled = !Config.fitToCanvas; _xBox.Enabled = !Config.fitToCanvas; _yBox.Enabled = !Config.fitToCanvas; // Scripts submenu var _scriptsMenu = new ToolStripMenuItem("Scripts"); _controlTracker.Add(_scriptsMenu); // Add menu var _addMenu = new ToolStripMenuItem("Add"); _controlTracker.Add(_addMenu); // Add camera movement script ToolStripItem _addCameraMovement = _addMenu.DropDownItems.Add("Camera Movement", null, (p1, p2) => { OpenFileDialog ofd = new OpenFileDialog(); string path = Path.Combine(Environment.CurrentDirectory, "UserData", "CameraPlus", "Scripts"); CameraMovement.CreateExampleScript(); ofd.InitialDirectory = path; ofd.Title = "Select a script"; ofd.FileOk += (sender, e) => { string file = ((OpenFileDialog)sender).FileName; if (File.Exists(file)) { Config.movementScriptPath = file; Config.Save(); AddMovementScript(); } }; ofd.ShowDialog(); CloseContextMenu(); }); _addCameraMovement.Enabled = !File.Exists(Config.movementScriptPath) || (Config.movementScriptPath == "SongMovementScript" || Config.movementScriptPath == String.Empty); // Add song camera movement script ToolStripItem _addSongMovement = _addMenu.DropDownItems.Add("Song Camera Movement", null, (p1, p2) => { Config.movementScriptPath = "SongMovementScript"; Config.Save(); AddMovementScript(); CloseContextMenu(); }); _addSongMovement.Enabled = Config.movementScriptPath != "SongMovementScript"; _scriptsMenu.DropDownItems.Add(_addMenu); // Remove menu var _removeMenu = new ToolStripMenuItem("Remove"); _controlTracker.Add(_removeMenu); // Remove camera movement script ToolStripItem _removeCameraMovement = _removeMenu.DropDownItems.Add("Camera Movement", null, (p1, p2) => { Config.movementScriptPath = String.Empty; if (_cameraMovement) { _cameraMovement.Shutdown(); } Config.Save(); CloseContextMenu(); }); _removeCameraMovement.Enabled = !_addCameraMovement.Enabled; // Remove song camera movement script ToolStripItem _removeSongMovement = _removeMenu.DropDownItems.Add("Song Camera Movement", null, (p1, p2) => { Config.movementScriptPath = String.Empty; if (_cameraMovement) { _cameraMovement.Shutdown(); } Config.Save(); CloseContextMenu(); }); _removeSongMovement.Enabled = !_addSongMovement.Enabled; _scriptsMenu.DropDownItems.Add(_removeMenu); _menuStrip.Items.Add(_scriptsMenu); // Extras submenu var _extrasMenu = new ToolStripMenuItem("Extras"); _controlTracker.Add(_extrasMenu); // Just the right number... _extrasMenu.DropDownItems.Add("Spawn 38 Cameras", null, (p1, p2) => { StartCoroutine(CameraUtilities.Spawn38Cameras()); CloseContextMenu(); }); _menuStrip.Items.Add(_extrasMenu); }