Skip to content

Commit f4be40c

Browse files
committed
Merge remote-tracking branch 'upstream/master' into development
2 parents 9e2a2a7 + b03d810 commit f4be40c

File tree

14 files changed

+237
-39
lines changed

14 files changed

+237
-39
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ The original Unity Explorer had a Freecam feature, but even if it was useful at
131131
- Added tilt support.
132132
- Added FOV control support.
133133
- Added near and far clip sliders on the Freecam panel, to cut out objects near the camera out of view, or include more scene objects on sight.
134+
- Added new freecam methods to increase compatibility across games.
134135
- Automatically disable the Cinemachine component if present when using the gameplay camera, to avoid the game from trying to take control.
135136
- Added a toggle to block the freecam from moving with user input.
136137
- Unlocked the mouse on freecam even when the mod UI is hidden.
@@ -143,6 +144,10 @@ You can click on the "Follow object" button on the panel and select the object y
143144

144145
By default the camera only follows the object's position, but you can also make it follow its rotation as if the camera was physically bound to the object by checking the "Follow Object Rotation" toggle. Should be useful for mimicking a car camera, a character POV, or creating motion blur.
145146

147+
### Look At Object
148+
149+
As a side note, you can also "look at" a specific object in the world to force the camera to look directly toward it no matter the camera movement.
150+
146151
### Game input block for Unity's legacy system
147152

148153
Added game input block for Unity's legacy system. You can now block (or unblock) the game's input when using the freecam, as long as the game is using the Unity Legacy Input system. If the game uses a custom solution or the latest Unity system then this won't work. Implementing this for Unity's new system is in the backlog, so if you find a game using it (should say "Initialized new InputSystem support." on the logs) then please let me know so I can implement it using that game!
@@ -188,6 +193,7 @@ It allows you to create nodes to build camera paths for videos and cinematics. F
188193
- Wait 3 seconds before start toggler.
189194
- Move nodes up or down on the list.
190195
- Control over the tension and alpha values of the path, which are curve constants that change the resulting path created from the nodes. Their effect can be clearly seen when visualizing the path, as explained below.
196+
- Saving and loading camera paths to reuse them in different sessions.
191197

192198
As a side note, the mod UI will be disabled once the path starts, to ease video recording.
193199

@@ -215,6 +221,8 @@ Alongside all of this, you can also open each character game object by clicking
215221

216222
For each animator, you can also spawn a Bones Panel. This panel will list all of the character's bones and meshes, and provide easy-to-access toggles to disable them and sliders to move them around, allowing you to pose a character to your liking.
217223

224+
You can also save and load poses across different characters (if they have the same skeleton) and sessions.
225+
218226
## Misc Panel
219227

220228
- HUD toggle.
Binary file not shown.

UnityEditorPackage/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.originalnicodr.cinematicunityexplorer",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"displayName": "CinematicUnityExplorer",
55
"description": "UnityExplorer fork focused on providing tools for creating marketing material for Unity games.",
66
"unity": "2017.1",

src/Cinematic/Cells/CamPathNodeCell.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,19 @@ public virtual GameObject CreateContent(GameObject parent)
4343
ButtonRef copyFovButton = UIFactory.CreateButton(UIRoot, "Copy Camera FoV", "Copy Camera FoV");
4444
UIFactory.SetLayoutElement(copyFovButton.GameObject, minWidth: 100, minHeight: 25, flexibleWidth: 9999);
4545
copyFovButton.OnClick += () => {
46-
point.fov = FreeCamPanel.ourCamera.fieldOfView;
47-
GetCamPathsPanel().controlPoints[index] = point;
46+
Camera freecam = FreeCamPanel.GetFreecam();
47+
if (freecam != null) {
48+
point.fov = freecam.fieldOfView;
49+
GetCamPathsPanel().controlPoints[index] = point;
50+
}
4851
};
4952

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

5861
ButtonRef moveUpButton = UIFactory.CreateButton(UIRoot, "MoveUp", "▲");

src/Cinematic/Cells/LightCell.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public virtual GameObject CreateContent(GameObject parent)
2929

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

9292
public static void CopyFreeCamTransform(GameObject obj){
93-
Camera freeCam = FreeCamPanel.ourCamera;
93+
Camera freeCam = FreeCamPanel.GetFreecam();
9494

9595
if (freeCam != null) {
9696
obj.transform.position = freeCam.transform.position;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Xml.Serialization;
5+
6+
namespace UnityExplorer.Serializers
7+
{
8+
public class CamPathSerializer
9+
{
10+
public static string Serialize(List<CatmullRom.CatmullRomPoint> points, float time, float alpha, float tension, bool closePath, string sceneName)
11+
{
12+
CamPathSerializeObject serializeObject = new CamPathSerializeObject(points, time, alpha, tension, closePath, sceneName);
13+
var serializer = new XmlSerializer(typeof(CamPathSerializeObject));
14+
using (var writer = new StringWriter())
15+
{
16+
serializer.Serialize(writer, serializeObject);
17+
return writer.ToString();
18+
}
19+
}
20+
21+
public static CamPathSerializeObject Deserialize(string xml)
22+
{
23+
var serializer = new XmlSerializer(typeof(CamPathSerializeObject));
24+
using (var reader = new StringReader(xml))
25+
{
26+
return ((CamPathSerializeObject)serializer.Deserialize(reader));
27+
}
28+
}
29+
}
30+
31+
public struct CamPathSerializeObject
32+
{
33+
public CamPathSerializeObject(List<CatmullRom.CatmullRomPoint> points, float time, float alpha, float tension, bool closePath, string sceneName)
34+
{
35+
this.points = points;
36+
this.time = time;
37+
this.tension = tension;
38+
this.alpha = alpha;
39+
this.closePath = closePath;
40+
this.sceneName = sceneName;
41+
}
42+
43+
public readonly List<CatmullRom.CatmullRomPoint> points;
44+
public readonly float time;
45+
public readonly float alpha;
46+
public readonly float tension;
47+
public readonly bool closePath;
48+
public readonly string sceneName;
49+
}
50+
}

src/Config/ConfigManager.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using UnityExplorer.UI;
2+
using UnityExplorer.UI.Panels;
23

34
namespace UnityExplorer.Config
45
{
@@ -30,8 +31,9 @@ public static class ConfigManager
3031
public static ConfigElement<string> Reflection_Signature_Blacklist;
3132
public static ConfigElement<bool> Reflection_Hide_NativeInfoPtrs;
3233
public static ConfigElement<bool> Auto_Scale_UI;
34+
public static ConfigElement<bool> Reset_Camera_Transform;
3335

34-
public static ConfigElement<bool> Default_Gameplay_Freecam;
36+
public static ConfigElement<FreeCamPanel.FreeCameraType> Default_Freecam;
3537
public static ConfigElement<KeyCode> Pause;
3638
public static ConfigElement<KeyCode> Frameskip;
3739
public static ConfigElement<KeyCode> Screenshot;
@@ -184,10 +186,14 @@ private static void CreateConfigElements()
184186
Auto_Scale_UI = new("Make the mod UI automatically scale with resolution",
185187
"Especially useful when running games in high resolutions and you are having a hard time reading the mods menu (requires restart).",
186188
true);
189+
190+
Reset_Camera_Transform = new("Reset Camera transform on freecam disable",
191+
"Reset the camera position and rotation between freecam sessions, so the freecam always starts from the gameplay position and rotation.",
192+
false);
187193

188-
Default_Gameplay_Freecam = new("Default Gameplay Freecam",
189-
"Turn this on if you want the default gameplay freecam toggle on the Freecam panel to be on on startup.",
190-
true);
194+
Default_Freecam = new("Default Freecam mode",
195+
"Default type of freecam selected on startup.",
196+
FreeCamPanel.FreeCameraType.New);
191197

192198
Pause = new("Pause",
193199
"Toggle the pause of the game.",

src/ExplorerCore.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace UnityExplorer
2020
public static class ExplorerCore
2121
{
2222
public const string NAME = "CinematicUnityExplorer";
23-
public const string VERSION = "1.2.0.1";
23+
public const string VERSION = "1.3.0.1";
2424
public const string AUTHOR = "originalnicodr, Sinai, yukieiji";
2525
public const string GUID = "com.originalnicodr.cinematicunityexplorer";
2626

@@ -205,6 +205,8 @@ private static void MakeUEUIScale(){
205205
foreach (CanvasScaler scaler in canvasScalers)
206206
{
207207
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
208+
scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
209+
scaler.matchWidthOrHeight = 0f;
208210
}
209211
}
210212
}

src/Loader/Standalone/Editor/ExplorerEditorBehaviour.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using UnityEngine;
99
using UnityExplorer.Config;
1010
using UnityExplorer.UI;
11+
using UnityExplorer.UI.Panels;
1112
using UniverseLib;
1213

1314
namespace UnityExplorer.Loader.Standalone
@@ -26,6 +27,9 @@ public class ExplorerEditorBehaviour : MonoBehaviour
2627
public bool Force_Unlock_Mouse = true;
2728
public KeyCode Force_Unlock_Toggle;
2829
public bool Disable_EventSystem_Override;
30+
public bool Auto_Scale_UI;
31+
public bool Reset_Camera_Transform;
32+
public FreeCamPanel.FreeCameraType Default_Freecam;
2933

3034
public KeyCode Pause;
3135
public KeyCode Frameskip;
@@ -80,6 +84,9 @@ internal void LoadConfigs()
8084
ConfigManager.Force_Unlock_Mouse.Value = this.Force_Unlock_Mouse;
8185
ConfigManager.Force_Unlock_Toggle.Value = this.Force_Unlock_Toggle;
8286
ConfigManager.Disable_EventSystem_Override.Value = this.Disable_EventSystem_Override;
87+
ConfigManager.Auto_Scale_UI.Value = this.Auto_Scale_UI;
88+
ConfigManager.Reset_Camera_Transform.Value = this.Reset_Camera_Transform;
89+
ConfigManager.Default_Freecam.Value = this.Default_Freecam;
8390

8491
ConfigManager.Pause.Value = this.Pause;
8592
ConfigManager.Frameskip.Value = this.Frameskip;

src/UI/Panels/BonesPanel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,19 @@ private void SaveBones(){
199199
}
200200

201201
string filename = saveLoadinputField.Component.text;
202-
if (filename.EndsWith(".xml") || filename.EndsWith(".XML")) filename = filename.Substring(filename.Length-4);
202+
if (filename.EndsWith(".cuepose") || filename.EndsWith(".CUEPOSE")) filename = filename.Substring(filename.Length-7);
203203
if (string.IsNullOrEmpty(filename)) filename = $"{animator?.name}-{DateTime.Now.ToString("yyyy-M-d HH-mm-ss")}";
204204
string posesPath = Path.Combine(ExplorerCore.ExplorerFolder, "Poses");
205205
System.IO.Directory.CreateDirectory(posesPath);
206206

207207
// Serialize
208208
string serializedData = BonesSerializer.Serialize(bonesTreeCache);
209-
File.WriteAllText($"{posesPath}\\{filename}.xml", serializedData);
209+
File.WriteAllText($"{posesPath}\\{filename}.cuepose", serializedData);
210210
}
211211

212212
private void LoadBones(){
213213
string filename = saveLoadinputField.Component.text;
214-
if (filename.EndsWith(".xml") || filename.EndsWith(".XML")) filename = filename.Substring(filename.Length-4);
214+
if (filename.EndsWith(".cuepose") || filename.EndsWith(".CUEPOSE")) filename = filename.Substring(filename.Length-7);
215215
if (string.IsNullOrEmpty(filename)){
216216
ExplorerCore.LogWarning("Empty file name. Please write the name of the file to load.");
217217
return;
@@ -220,7 +220,7 @@ private void LoadBones(){
220220
string posesPath = Path.Combine(ExplorerCore.ExplorerFolder, "Poses");
221221
string xml;
222222
try {
223-
xml = File.ReadAllText($"{posesPath}\\{filename}.xml");
223+
xml = File.ReadAllText($"{posesPath}\\{filename}.cuepose");
224224
}
225225
catch (Exception ex) {
226226
ExplorerCore.LogWarning(ex);

0 commit comments

Comments
 (0)