mirror of
https://github.com/originalnicodr/CinematicUnityExplorer.git
synced 2026-10-10 04:53:15 +08:00
Added option to make the camera follow an in-game object. Also made a toggle to block the freecam from moving with user input.
This commit is contained in:
@@ -351,3 +351,4 @@ MigrationBackup/
|
|||||||
|
|
||||||
# Ionide (cross platform F# VS Code tools) working folder
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
.ionide/
|
.ionide/
|
||||||
|
build-bep5mono.ps1
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ namespace UnityExplorer.Inspectors
|
|||||||
public override Vector2 DefaultAnchorMax => Vector2.zero;
|
public override Vector2 DefaultAnchorMax => Vector2.zero;
|
||||||
|
|
||||||
public override bool CanDragAndResize => false;
|
public override bool CanDragAndResize => false;
|
||||||
|
private Action<GameObject> inspectorAction = null;
|
||||||
|
|
||||||
internal Text objNameLabel;
|
internal Text objNameLabel;
|
||||||
internal Text objPathLabel;
|
internal Text objPathLabel;
|
||||||
@@ -61,13 +62,13 @@ namespace UnityExplorer.Inspectors
|
|||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
case 0: return;
|
case 0: return;
|
||||||
case 1: Instance.StartInspect(MouseInspectMode.World); break;
|
case 1: Instance.StartInspect(MouseInspectMode.World, (obj) => InspectorManager.Inspect(obj, null)); break;
|
||||||
case 2: Instance.StartInspect(MouseInspectMode.UI); break;
|
case 2: Instance.StartInspect(MouseInspectMode.UI, (obj) => InspectorManager.Inspect(obj, null)); break;
|
||||||
}
|
}
|
||||||
InspectorPanel.Instance.MouseInspectDropdown.value = 0;
|
InspectorPanel.Instance.MouseInspectDropdown.value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartInspect(MouseInspectMode mode)
|
public void StartInspect(MouseInspectMode mode, Action<GameObject> newInspectorAction)
|
||||||
{
|
{
|
||||||
Mode = mode;
|
Mode = mode;
|
||||||
Inspecting = true;
|
Inspecting = true;
|
||||||
@@ -80,6 +81,8 @@ namespace UnityExplorer.Inspectors
|
|||||||
UIManager.UiBase.SetOnTop();
|
UIManager.UiBase.SetOnTop();
|
||||||
|
|
||||||
SetActive(true);
|
SetActive(true);
|
||||||
|
|
||||||
|
inspectorAction = newInspectorAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void ClearHitData()
|
internal void ClearHitData()
|
||||||
@@ -111,10 +114,10 @@ namespace UnityExplorer.Inspectors
|
|||||||
public bool TryUpdate()
|
public bool TryUpdate()
|
||||||
{
|
{
|
||||||
if (InputManager.GetKeyDown(ConfigManager.World_MouseInspect_Keybind.Value))
|
if (InputManager.GetKeyDown(ConfigManager.World_MouseInspect_Keybind.Value))
|
||||||
Instance.StartInspect(MouseInspectMode.World);
|
Instance.StartInspect(MouseInspectMode.World, inspectorAction);
|
||||||
|
|
||||||
if (InputManager.GetKeyDown(ConfigManager.UI_MouseInspect_Keybind.Value))
|
if (InputManager.GetKeyDown(ConfigManager.UI_MouseInspect_Keybind.Value))
|
||||||
Instance.StartInspect(MouseInspectMode.UI);
|
Instance.StartInspect(MouseInspectMode.UI, inspectorAction);
|
||||||
|
|
||||||
if (Inspecting)
|
if (Inspecting)
|
||||||
UpdateInspect();
|
UpdateInspect();
|
||||||
@@ -132,7 +135,7 @@ namespace UnityExplorer.Inspectors
|
|||||||
|
|
||||||
if (InputManager.GetMouseButtonDown(0))
|
if (InputManager.GetMouseButtonDown(0))
|
||||||
{
|
{
|
||||||
CurrentInspector.OnSelectMouseInspect();
|
CurrentInspector.OnSelectMouseInspect(inspectorAction);
|
||||||
StopInspect();
|
StopInspect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
public abstract void UpdateMouseInspect(Vector2 mousePos);
|
public abstract void UpdateMouseInspect(Vector2 mousePos);
|
||||||
|
|
||||||
public abstract void OnSelectMouseInspect();
|
public abstract void OnSelectMouseInspect(Action<GameObject> inspectorAction);
|
||||||
|
|
||||||
public abstract void ClearHitData();
|
public abstract void ClearHitData();
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
|||||||
currentHitObjects.Clear();
|
currentHitObjects.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnSelectMouseInspect()
|
public override void OnSelectMouseInspect(Action<GameObject> inspectorAction)
|
||||||
{
|
{
|
||||||
|
// need to properly handle inspectorAction here
|
||||||
LastHitObjects.Clear();
|
LastHitObjects.Clear();
|
||||||
LastHitObjects.AddRange(currentHitObjects);
|
LastHitObjects.AddRange(currentHitObjects);
|
||||||
RuntimeHelper.StartCoroutine(SetPanelActiveCoro());
|
RuntimeHelper.StartCoroutine(SetPanelActiveCoro());
|
||||||
|
|||||||
@@ -21,9 +21,9 @@
|
|||||||
lastHitObject = null;
|
lastHitObject = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnSelectMouseInspect()
|
public override void OnSelectMouseInspect(Action<GameObject> inspectorAction)
|
||||||
{
|
{
|
||||||
InspectorManager.Inspect(lastHitObject);
|
inspectorAction(lastHitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UpdateMouseInspect(Vector2 mousePos)
|
public override void UpdateMouseInspect(Vector2 mousePos)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using UniverseLib.Input;
|
using UniverseLib.Input;
|
||||||
|
using UnityExplorer.Inspectors;
|
||||||
using UniverseLib.UI;
|
using UniverseLib.UI;
|
||||||
using UniverseLib.UI.Models;
|
using UniverseLib.UI.Models;
|
||||||
#if UNHOLLOWER
|
#if UNHOLLOWER
|
||||||
@@ -45,6 +46,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
|
|
||||||
static ButtonRef startStopButton;
|
static ButtonRef startStopButton;
|
||||||
static Toggle useGameCameraToggle;
|
static Toggle useGameCameraToggle;
|
||||||
|
public static Toggle blockFreecamMovementToggle;
|
||||||
static InputFieldRef positionInput;
|
static InputFieldRef positionInput;
|
||||||
static InputFieldRef moveSpeedInput;
|
static InputFieldRef moveSpeedInput;
|
||||||
static ButtonRef inspectButton;
|
static ButtonRef inspectButton;
|
||||||
@@ -184,11 +186,11 @@ namespace UnityExplorer.UI.Panels
|
|||||||
|
|
||||||
AddSpacer(5);
|
AddSpacer(5);
|
||||||
|
|
||||||
GameObject toggleObj = UIFactory.CreateToggle(ContentRoot, "UseGameCameraToggle", out useGameCameraToggle, out Text toggleText);
|
GameObject toggleObj = UIFactory.CreateToggle(ContentRoot, "UseGameCameraToggle", out useGameCameraToggle, out Text useGameCameraText);
|
||||||
UIFactory.SetLayoutElement(toggleObj, minHeight: 25, flexibleWidth: 9999);
|
UIFactory.SetLayoutElement(toggleObj, minHeight: 25, flexibleWidth: 9999);
|
||||||
useGameCameraToggle.onValueChanged.AddListener(OnUseGameCameraToggled);
|
useGameCameraToggle.onValueChanged.AddListener(OnUseGameCameraToggled);
|
||||||
useGameCameraToggle.isOn = false;
|
useGameCameraToggle.isOn = false;
|
||||||
toggleText.text = "Use Game Camera?";
|
useGameCameraText.text = "Use Game Camera?";
|
||||||
|
|
||||||
AddSpacer(5);
|
AddSpacer(5);
|
||||||
|
|
||||||
@@ -205,6 +207,21 @@ namespace UnityExplorer.UI.Panels
|
|||||||
|
|
||||||
AddSpacer(5);
|
AddSpacer(5);
|
||||||
|
|
||||||
|
ButtonRef followButton = UIFactory.CreateButton(ContentRoot, "FollowButton", "Make camera Follow Gameobject");
|
||||||
|
UIFactory.SetLayoutElement(followButton.GameObject, minWidth: 150, minHeight: 25, flexibleWidth: 9999);
|
||||||
|
followButton.OnClick += FollowButton_OnClick;
|
||||||
|
|
||||||
|
AddSpacer(5);
|
||||||
|
|
||||||
|
GameObject blockFreecamMovement = UIFactory.CreateToggle(ContentRoot, "blockFreecamMovement", out blockFreecamMovementToggle, out Text blockFreecamMovementText);
|
||||||
|
UIFactory.SetLayoutElement(blockFreecamMovement, minHeight: 25, flexibleWidth: 9999);
|
||||||
|
blockFreecamMovementToggle.onValueChanged.AddListener(OnUseGameCameraToggled);
|
||||||
|
blockFreecamMovementToggle.isOn = false;
|
||||||
|
blockFreecamMovementText.text = "Block Freecam movement";
|
||||||
|
|
||||||
|
AddSpacer(5);
|
||||||
|
|
||||||
|
|
||||||
string instructions = @"Controls:
|
string instructions = @"Controls:
|
||||||
- WASD / Arrows: Movement
|
- WASD / Arrows: Movement
|
||||||
- Space / PgUp: Move up
|
- Space / PgUp: Move up
|
||||||
@@ -260,6 +277,19 @@ namespace UnityExplorer.UI.Panels
|
|||||||
SetToggleButtonState();
|
SetToggleButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void temporalAction(GameObject obj){
|
||||||
|
if(!ourCamera){
|
||||||
|
ExplorerCore.LogWarning("Error: Start the freecam at least once before setting a follow object.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ourCamera.transform.SetParent(obj.transform, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FollowButton_OnClick()
|
||||||
|
{
|
||||||
|
MouseInspector.Instance.StartInspect(MouseInspectMode.World, temporalAction);
|
||||||
|
}
|
||||||
|
|
||||||
void SetToggleButtonState()
|
void SetToggleButtonState()
|
||||||
{
|
{
|
||||||
if (inFreeCamMode)
|
if (inFreeCamMode)
|
||||||
@@ -349,6 +379,10 @@ namespace UnityExplorer.UI.Panels
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FreeCamPanel.blockFreecamMovementToggle.isOn){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Transform transform = FreeCamPanel.ourCamera.transform;
|
Transform transform = FreeCamPanel.ourCamera.transform;
|
||||||
|
|
||||||
FreeCamPanel.currentUserCameraPosition = transform.position;
|
FreeCamPanel.currentUserCameraPosition = transform.position;
|
||||||
|
|||||||
Reference in New Issue
Block a user