Skip to content

Commit

Permalink
Added new freecam methods, one for cloning the gameplay camera and an…
Browse files Browse the repository at this point in the history
…other one for replacing the worldToCameraMatrix of the gameplay camera.
  • Loading branch information
originalnicodr committed Nov 23, 2024
1 parent c9aa93a commit 736ebdf
Show file tree
Hide file tree
Showing 6 changed files with 399 additions and 88 deletions.
9 changes: 6 additions & 3 deletions src/Cinematic/Cells/CamPathNodeCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,19 @@ public virtual GameObject CreateContent(GameObject parent)
ButtonRef copyFovButton = UIFactory.CreateButton(UIRoot, "Copy Camera FoV", "Copy Camera FoV");
UIFactory.SetLayoutElement(copyFovButton.GameObject, minWidth: 100, minHeight: 25, flexibleWidth: 9999);
copyFovButton.OnClick += () => {
point.fov = FreeCamPanel.ourCamera.fieldOfView;
GetCamPathsPanel().controlPoints[index] = point;
Camera freecam = FreeCamPanel.GetFreecam();
if (freecam != null) {
point.fov = freecam.fieldOfView;
GetCamPathsPanel().controlPoints[index] = point;
}
};

ButtonRef moveToPointButton = UIFactory.CreateButton(UIRoot, "Move Cam to Node", "Move Cam to Node");
UIFactory.SetLayoutElement(moveToPointButton.GameObject, minWidth: 100, minHeight: 25, flexibleWidth: 9999);
moveToPointButton.OnClick += () => {
FreeCamPanel.SetCameraRotation(point.rotation);
FreeCamPanel.SetCameraPosition(point.position);
FreeCamPanel.ourCamera.fieldOfView = point.fov;
FreeCamPanel.SetFOV(point.fov);
};

ButtonRef moveUpButton = UIFactory.CreateButton(UIRoot, "MoveUp", "▲");
Expand Down
4 changes: 2 additions & 2 deletions src/Cinematic/Cells/LightCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public virtual GameObject CreateContent(GameObject parent)

//Active toggle
Toggle toggleLight;
GameObject toggleObj = UIFactory.CreateToggle(UIRoot, "UseGameCameraToggle", out toggleLight, out label);
GameObject toggleObj = UIFactory.CreateToggle(UIRoot, "ActivateLightToggle", out toggleLight, out label);
UIFactory.SetLayoutElement(toggleObj, minHeight: 25, flexibleWidth: 9999);
toggleLight.onValueChanged.AddListener(value => { light.SetActive(value); });
toggleLight.isOn = true;
Expand Down Expand Up @@ -90,7 +90,7 @@ private void DestroyLight(){
}

public static void CopyFreeCamTransform(GameObject obj){
Camera freeCam = FreeCamPanel.ourCamera;
Camera freeCam = FreeCamPanel.GetFreecam();

if (freeCam != null) {
obj.transform.position = freeCam.transform.position;
Expand Down
9 changes: 5 additions & 4 deletions src/Config/ConfigManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityExplorer.UI;
using UnityExplorer.UI.Panels;

namespace UnityExplorer.Config
{
Expand Down Expand Up @@ -31,7 +32,7 @@ public static class ConfigManager
public static ConfigElement<bool> Reflection_Hide_NativeInfoPtrs;
public static ConfigElement<bool> Auto_Scale_UI;

public static ConfigElement<bool> Default_Gameplay_Freecam;
public static ConfigElement<FreeCamPanel.FreeCameraType> Default_Freecam;
public static ConfigElement<KeyCode> Pause;
public static ConfigElement<KeyCode> Frameskip;
public static ConfigElement<KeyCode> Screenshot;
Expand Down Expand Up @@ -185,9 +186,9 @@ private static void CreateConfigElements()
"Especially useful when running games in high resolutions and you are having a hard time reading the mods menu (requires restart).",
true);

Default_Gameplay_Freecam = new("Default Gameplay Freecam",
"Turn this on if you want the default gameplay freecam toggle on the Freecam panel to be on on startup.",
false);
Default_Freecam = new("Default Freecam mode",
"Default type of freecam selected on startup.",
FreeCamPanel.FreeCameraType.New);

Pause = new("Pause",
"Toggle the pause of the game.",
Expand Down
6 changes: 3 additions & 3 deletions src/UI/Panels/CamPaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ protected override void ConstructPanelContent()
default, new Color(1, 1, 1, 0), TextAnchor.MiddleLeft);
UIFactory.SetLayoutElement(horiGroup, minHeight: 25, flexibleWidth: 9999);

ButtonRef startButton = UIFactory.CreateButton(horiGroup, "Start", "►");
ButtonRef startButton = UIFactory.CreateButton(horiGroup, "Start", "►", new Color(0.2f, 0.4f, 0.2f));
UIFactory.SetLayoutElement(startButton.GameObject, minWidth: 50, minHeight: 25);
startButton.OnClick += StartButton_OnClick;

ButtonRef pauseContinueButton = UIFactory.CreateButton(horiGroup, "Pause/Continue", "❚❚/►");
UIFactory.SetLayoutElement(pauseContinueButton.GameObject, minWidth: 50, minHeight: 25);
pauseContinueButton.OnClick += TogglePause_OnClick;

ButtonRef stopButton = UIFactory.CreateButton(horiGroup, "Stop", "■");
ButtonRef stopButton = UIFactory.CreateButton(horiGroup, "Stop", "■", new Color(0.4f, 0.2f, 0.2f));
UIFactory.SetLayoutElement(stopButton.GameObject, minWidth: 50, minHeight: 25);
stopButton.ButtonText.fontSize = 20;
stopButton.OnClick += Stop_OnClick;
Expand Down Expand Up @@ -364,7 +364,7 @@ void AddNode_OnClick(){
CatmullRom.CatmullRomPoint point = new CatmullRom.CatmullRomPoint(
FreeCamPanel.GetCameraPosition(),
FreeCamPanel.GetCameraRotation(),
FreeCamPanel.ourCamera.fieldOfView
FreeCamPanel.GetFreecam().fieldOfView
);

controlPoints.Add(point);
Expand Down
Loading

0 comments on commit 736ebdf

Please sign in to comment.