1
0
mirror of https://github.com/originalnicodr/CinematicUnityExplorer.git synced 2026-10-10 13:03:15 +08:00

Added more controller hotkeys,

This commit is contained in:
Nicolás Uriel Navall
2025-11-29 19:47:45 -03:00
parent 887af608db
commit 4a442e2bbc
6 changed files with 216 additions and 25 deletions
+15 -7
View File
@@ -102,7 +102,7 @@ The table below describes all of the relevant default hotkeys. You can edit them
Feature | Keyboard | Gamepad
-|-|-
Freecam | `Insert` |
Freecam toggle | `Insert` | `R3 + X`
Move the camera forward/left/backward/right | `W`/`A`/`S`/`D` - `UpArrow`/`LeftArrow`/`DownArrow`/`RightArrow`/ | Left stick
Move the camera upwards | `Space` | `LT`
Move the camera downwards | `LeftControl` | `RT`
@@ -115,12 +115,20 @@ Reset tilt | `Numpad 2` | `A`
Decrease FOV | `Numpad -` | Dpad up
Increase FOV | `Numpad +` | Dpad down
Reset FOV | `Numpad *` | `B`
Pause | `PageUp`
Block Freecam movement and rotation | `Home`
Block games input | `Numpad .`
Frameskip | `PageDown`
HUD Toggle | `Delete`
Freeze NPC animations | `Numpad 0`
Pause | `PageUp` |
Block Freecam movement and rotation | `Home` |
Block games input | `Numpad .` |
Frameskip | `PageDown` |
HUD Toggle | `Delete` |
Freeze NPC animations | `Numpad 0` |
Time scale override toggle | | `L3 + X`
Decrease time scale | | `X + L1`
Increase time scale | | `X + R1`
Camera path: Add node | | `A`
Camera path: Navigate to previous node | | `L1`
Camera path: Navigate to next node | | `R1`
Camera path: Start/stop playback | | `START`
Camera path: Pause/unpause playback | | `SELECT`
> [!NOTE]
> Gamepad is only compatible if the game is using [Unity Input System](https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/index.html).
+2
View File
@@ -87,7 +87,9 @@ namespace UnityExplorer.UI.Panels
ButtonRef destroyButton = UIFactory.CreateButton(UIRoot, "Delete", "Delete");
UIFactory.SetLayoutElement(destroyButton.GameObject, minWidth: 30, minHeight: 25, flexibleWidth: 9999);
destroyButton.OnClick += () => {
int deletedIndex = GetCamPathsPanel().controlPoints.IndexOf(point);
GetCamPathsPanel().controlPoints.Remove(point);
GetCamPathsPanel().OnNodeDeleted(deletedIndex);
GetCamPathsPanel().nodesScrollPool.Refresh(true, false);
GetCamPathsPanel().MaybeRedrawPath();
};
+25 -1
View File
@@ -131,7 +131,7 @@ namespace UnityExplorer
if (IInputManager.GetKeyDown(ConfigManager.Freecam_Toggle.Value))
{
FreeCamPanel.StartStopButton_OnClick();
FreeCamPanel.ToggleFreecam();
}
if (IInputManager.GetKeyDown(ConfigManager.Block_Freecam_Movement.Value))
@@ -148,6 +148,30 @@ namespace UnityExplorer
{
FreeCamPanel.blockGamesInputOnFreecamToggle.isOn = !FreeCamPanel.blockGamesInputOnFreecamToggle.isOn;
}
// Gamepad controls
bool xButtonPressed = IGamepadInputInterceptor.IsButtonPressed("/gamepad/buttonwest");
bool leftStickButton = IGamepadInputInterceptor.IsButtonPressed("/gamepad/leftstickpress");
bool rightStickButton = IGamepadInputInterceptor.IsButtonPressed("/gamepad/rightstickpress");
// L3 + X: Toggle time scale override
if (xButtonPressed && leftStickButton)
{
if (IGamepadInputInterceptor.WasButtonPressedThisFrame("/gamepad/buttonwest") ||
IGamepadInputInterceptor.WasButtonPressedThisFrame("/gamepad/leftstickpress"))
{
UIManager.GetTimeScaleWidget().ToggleOverride();
}
}
// R3 + X: Toggle freecam
else if (xButtonPressed && rightStickButton)
{
if (IGamepadInputInterceptor.WasButtonPressedThisFrame("/gamepad/buttonwest") ||
IGamepadInputInterceptor.WasButtonPressedThisFrame("/gamepad/rightstickpress"))
{
FreeCamPanel.ToggleFreecam();
}
}
}
void stopFrameSkip(){
+77 -13
View File
@@ -43,6 +43,7 @@ namespace UnityExplorer.UI.Panels
public List<CatmullRom.CatmullRomPoint> controlPoints = new List<CatmullRom.CatmullRomPoint>();
bool closedLoop;
float time = 10;
public int currentSelectedNodeIndex = -1;
public GameObject followObject;
@@ -99,6 +100,8 @@ namespace UnityExplorer.UI.Panels
cell.point = point;
cell.index = index;
cell.indexLabel.text = $"{index}";
cell.indexLabel.color = (index == currentSelectedNodeIndex) ? Color.green : Color.white;
}
// ~~~~~~~~ UI construction / callbacks ~~~~~~~~
@@ -122,10 +125,10 @@ namespace UnityExplorer.UI.Panels
stopButton.ButtonText.fontSize = 20;
stopButton.OnClick += Stop_OnClick;
ButtonRef AddNode = UIFactory.CreateButton(horiGroup, "AddCamNode", "+");
UIFactory.SetLayoutElement(AddNode.GameObject, minWidth: 50, minHeight: 25);
AddNode.ButtonText.fontSize = 20;
AddNode.OnClick += AddNode_OnClick;
ButtonRef AddNodeButton = UIFactory.CreateButton(horiGroup, "AddCamNode", "+");
UIFactory.SetLayoutElement(AddNodeButton.GameObject, minWidth: 50, minHeight: 25);
AddNodeButton.ButtonText.fontSize = 20;
AddNodeButton.OnClick += AddNode;
ButtonRef DeletePath = UIFactory.CreateButton(horiGroup, "DeletePath", "Clear");
UIFactory.SetLayoutElement(DeletePath.GameObject, minWidth: 70, minHeight: 25);
@@ -337,20 +340,22 @@ namespace UnityExplorer.UI.Panels
void StartButton_OnClick()
{
StartPath();
}
public void StartPath(){
if (waitBeforePlay) {
if (startTimer.Enabled){
startTimer.Stop();
}
startTimer.Enabled = true;
} else {
StartPath();
return;
}
EventSystemHelper.SetSelectedGameObject(null);
}
void StartPath(){
if (GetCameraPathsManager()){
UpdateCatmullRomMoverData();
GetCameraPathsManager().StartPath();
@@ -363,7 +368,7 @@ namespace UnityExplorer.UI.Panels
}
}
void TogglePause_OnClick(){
public void TogglePause(){
if(GetCameraPathsManager()){
GetCameraPathsManager().TogglePause();
if (visualizePathToggle.isOn && GetCameraPathsManager().IsPaused()) visualizePathToggle.isOn = false;
@@ -372,7 +377,11 @@ namespace UnityExplorer.UI.Panels
EventSystemHelper.SetSelectedGameObject(null);
}
void Stop_OnClick(){
void TogglePause_OnClick(){
TogglePause();
}
public void StopPath(){
if (GetCameraPathsManager()){
GetCameraPathsManager().Stop();
}
@@ -380,7 +389,11 @@ namespace UnityExplorer.UI.Panels
EventSystemHelper.SetSelectedGameObject(null);
}
void AddNode_OnClick(){
void Stop_OnClick(){
StopPath();
}
public void AddNode(){
EventSystemHelper.SetSelectedGameObject(null);
CatmullRom.CatmullRomPoint point = new CatmullRom.CatmullRomPoint(
@@ -390,6 +403,7 @@ namespace UnityExplorer.UI.Panels
);
controlPoints.Add(point);
currentSelectedNodeIndex = controlPoints.Count - 1;
nodesScrollPool.Refresh(true, false);
MaybeRedrawPath();
}
@@ -528,6 +542,56 @@ namespace UnityExplorer.UI.Panels
File.WriteAllText($"{camPathsFolderPath}\\{filename}.cuepath", serializedData);
}
void NavigateToNode(int nodeIndex)
{
if (nodeIndex < 0 || nodeIndex >= controlPoints.Count)
return;
currentSelectedNodeIndex = nodeIndex;
CatmullRom.CatmullRomPoint point = controlPoints[nodeIndex];
FreeCamPanel.SetCameraPosition(point.position);
FreeCamPanel.SetCameraRotation(point.rotation);
FreeCamPanel.SetFOV(point.fov);
nodesScrollPool.Refresh(true, false);
}
public void NavigateToNextNode()
{
if (controlPoints.Count == 0)
return;
int nextIndex = (currentSelectedNodeIndex + 1) % controlPoints.Count;
NavigateToNode(nextIndex);
}
public void NavigateToPreviousNode()
{
if (controlPoints.Count == 0)
return;
int prevIndex = currentSelectedNodeIndex - 1;
if (prevIndex < 0)
prevIndex = controlPoints.Count - 1;
NavigateToNode(prevIndex);
}
public void OnNodeDeleted(int deletedIndex)
{
// If the current selected index is out of bounds, adjust it
if (currentSelectedNodeIndex >= controlPoints.Count)
{
currentSelectedNodeIndex = controlPoints.Count - 1;
}
// If we deleted the selected node or a node before it, adjust the index
else if (deletedIndex <= currentSelectedNodeIndex && currentSelectedNodeIndex > 0)
{
currentSelectedNodeIndex--;
}
if (controlPoints.Count == 0)
currentSelectedNodeIndex = -1;
}
private void LoadPath(){
string filename = saveLoadInputField.Component.text;
if (filename.EndsWith(".cuepath") || filename.EndsWith(".CUEPATH")) filename = filename.Substring(filename.Length-7);
@@ -563,12 +627,12 @@ namespace UnityExplorer.UI.Panels
// We enable the freecam so we can use it to spawn the camera path relative to it
if (!FreeCamPanel.inFreeCamMode) {
FreeCamPanel.StartStopButton_OnClick();
FreeCamPanel.ToggleFreecam();
}
controlPoints.Clear();
// The first point will be the camera position, and we adapt the following points from there
AddNode_OnClick();
AddNode();
CatmullRom.CatmullRomPoint startingPoint = controlPoints.ElementAt(0);
CatmullRom.CatmullRomPoint originalStartingPoint = deserializedObj.points.ElementAt(0);
+76 -4
View File
@@ -802,7 +802,7 @@ namespace UnityExplorer.UI.Panels
return row;
}
public static void StartStopButton_OnClick()
public static void ToggleFreecam()
{
EventSystemHelper.SetSelectedGameObject(null);
@@ -814,6 +814,11 @@ namespace UnityExplorer.UI.Panels
SetToggleButtonState();
}
public static void StartStopButton_OnClick()
{
ToggleFreecam();
}
public static void FollowObjectAction(GameObject obj){
ReleaseFollowLookAtButton_OnClick();
@@ -1210,6 +1215,7 @@ namespace UnityExplorer.UI.Panels
private Action onBeforeRenderAction;
private Vector3 cachedPosition;
private Quaternion cachedRotation;
private CamPaths cachedCamPathsPanel;
internal void Update()
{
@@ -1220,6 +1226,10 @@ namespace UnityExplorer.UI.Panels
FreeCamPanel.EndFreecam();
return;
}
if (cachedCamPathsPanel == null)
cachedCamPathsPanel = UIManager.GetPanel<CamPaths>(UIManager.Panels.CamPaths);
Transform movingTransform = FreeCamPanel.GetFreecam().transform;
if (!FreeCamPanel.blockFreecamMovementToggle.isOn && !FreeCamPanel.cameraPathMover.playingPath && FreeCamPanel.connector?.IsActive != true && !IsInputFieldInFocus()) {
@@ -1332,13 +1342,23 @@ namespace UnityExplorer.UI.Panels
float rightTrigger = IGamepadInputInterceptor.GetAxisValue("/gamepad/righttrigger");
bool yButtonPressed = IGamepadInputInterceptor.IsButtonPressed("/gamepad/buttonnorth");
bool xButtonPressed = IGamepadInputInterceptor.IsButtonPressed("/gamepad/buttonwest");
bool aButtonPressed = IGamepadInputInterceptor.IsButtonPressed("/gamepad/buttonsouth");
bool bButtonPressed = IGamepadInputInterceptor.IsButtonPressed("/gamepad/buttoneast");
bool dpadUpPressed = IGamepadInputInterceptor.IsButtonPressed("/gamepad/dpad/up");
bool dpadDownPressed = IGamepadInputInterceptor.IsButtonPressed("/gamepad/dpad/down");
bool dpadLeftPressed = IGamepadInputInterceptor.IsButtonPressed("/gamepad/dpad/left");
bool dpadRightPressed = IGamepadInputInterceptor.IsButtonPressed("/gamepad/dpad/right");
bool leftStickButton = IGamepadInputInterceptor.IsButtonPressed("/gamepad/leftstickpress");
bool rightStickButton = IGamepadInputInterceptor.IsButtonPressed("/gamepad/rightstickpress");
bool aButtonPressedThisFrame = IGamepadInputInterceptor.WasButtonPressedThisFrame("/gamepad/buttonsouth");
bool leftShoulderPressed = IGamepadInputInterceptor.WasButtonPressedThisFrame("/gamepad/leftshoulder");
bool rightShoulderPressed = IGamepadInputInterceptor.WasButtonPressedThisFrame("/gamepad/rightshoulder");
bool startButtonPressed = IGamepadInputInterceptor.WasButtonPressedThisFrame("/gamepad/start");
bool selectButtonPressed = IGamepadInputInterceptor.WasButtonPressedThisFrame("/gamepad/select");
float moveSpeed = FreeCamPanel.desiredMoveSpeed * 0.01665f; //"0.01665f" (60fps) in place of Time.DeltaTime. DeltaTime causes issues when game is paused.
float speedModifier = 1;
if (IInputManager.GetKey(ConfigManager.Speed_Up_Movement.Value) || yButtonPressed)
@@ -1403,7 +1423,7 @@ namespace UnityExplorer.UI.Panels
}
}
if (IInputManager.GetKey(ConfigManager.Tilt_Reset.Value) || aButtonPressed){
if (IInputManager.GetKey(ConfigManager.Tilt_Reset.Value) || (leftStickButton && bButtonPressed)){
// Extract the forward direction of the original quaternion
Vector3 forwardDirection = transform.rotation * Vector3.forward;
// Reset the tilt by creating a new quaternion with no tilt
@@ -1464,10 +1484,62 @@ namespace UnityExplorer.UI.Panels
FreeCamPanel.GetFreecam().fieldOfView += moveSpeed * 3;
}
if (IInputManager.GetKey(ConfigManager.Reset_FOV.Value) || bButtonPressed){
if (IInputManager.GetKey(ConfigManager.Reset_FOV.Value) || (bButtonPressed && !leftStickButton)){
FreeCamPanel.GetFreecam().fieldOfView = FreeCamPanel.currentCameraType == FreeCamPanel.FreeCameraType.New ? 60 : FreeCamPanel.originalCameraFOV;
}
// Time scale gamepad controls
if (xButtonPressed)
{
if (leftShoulderPressed)
{
UIManager.GetTimeScaleWidget().DecreaseTimeScale();
}
else if (rightShoulderPressed)
{
UIManager.GetTimeScaleWidget().IncreaseTimeScale();
}
}
// Camera path gamepad controls
if (cachedCamPathsPanel != null)
{
if (aButtonPressedThisFrame)
{
cachedCamPathsPanel.AddNode();
}
if (leftShoulderPressed)
{
cachedCamPathsPanel.NavigateToPreviousNode();
}
if (rightShoulderPressed)
{
cachedCamPathsPanel.NavigateToNextNode();
}
if (startButtonPressed)
{
if (FreeCamPanel.cameraPathMover.playingPath)
{
cachedCamPathsPanel.StopPath();
}
else
{
cachedCamPathsPanel.StartPath();
}
}
if (selectButtonPressed)
{
if (FreeCamPanel.cameraPathMover.playingPath)
{
cachedCamPathsPanel.TogglePause();
}
}
}
FreeCamPanel.previousMousePosition = IInputManager.MousePosition;
}
+21
View File
@@ -68,6 +68,27 @@ namespace UnityExplorer.UI.Widgets
settingTimeScale = false;
}
public void IncreaseTimeScale()
{
float newValue = Mathf.Min(desiredTime + 0.1f, slider.maxValue);
slider.value = newValue;
if (overrideTimeScaleToggle.isOn)
SetTimeScale(newValue);
}
public void DecreaseTimeScale()
{
float newValue = Mathf.Max(desiredTime - 0.1f, slider.minValue);
slider.value = newValue;
if (overrideTimeScaleToggle.isOn)
SetTimeScale(newValue);
}
public void ToggleOverride()
{
overrideTimeScaleToggle.isOn = !overrideTimeScaleToggle.isOn;
}
// UI event listeners
void OnTimeInputEndEdit(string val)