This repository has been archived by the owner on Mar 12, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMain.cs
542 lines (481 loc) · 31.1 KB
/
Main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DesktopCamera.Buttons;
using DesktopCamera.Utils;
using MelonLoader;
using UnityEngine.Networking;
using Il2CppSystem.Text;
using Newtonsoft.Json;
using System.Collections;
using VRC.SDKBase;
namespace DesktopCamera {
public static class ModBuildInfo {
public const string Name = "DesktopCamera";
public const string Author = "nitro.";
public const string Company = null;
public const string Version = "1.1.3";
public const string DownloadLink = "https://github.com/nitrog0d/DesktopCamera/releases/latest/download/DesktopCamera.dll";
public const string GameDeveloper = "VRChat";
public const string Game = "VRChat";
}
public class VersionCheckResponse {
public string result { get; set; }
public string latest { get; set; }
}
public class Main : MelonMod {
private const string ModCategory = "DesktopCamera";
private const string CameraSpeedPref = "CameraSpeed";
private const string CameraSpeedAltPref = "CameraSpeedAlt";
private static float CameraSpeed = 0.005f;
private static float CameraSpeedAlt = 0.020f;
public override void OnApplicationStart() {
MelonLogger.Msg("Mod loaded.");
MelonPreferences.CreateCategory(ModCategory, "DesktopCamera");
MelonPreferences.CreateEntry(ModCategory, CameraSpeedPref, 5, "Basic camera speed");
MelonPreferences.CreateEntry(ModCategory, CameraSpeedAltPref, 20, "Alt camera speed (ALT pressed)");
OnPreferencesSaved();
}
public override void OnPreferencesSaved() {
CameraSpeed = MelonPreferences.GetEntryValue<int>(ModCategory, CameraSpeedPref);
CameraSpeedAlt = MelonPreferences.GetEntryValue<int>(ModCategory, CameraSpeedAltPref);
CameraSpeed /= 1000;
CameraSpeedAlt /= 1000;
}
public override void VRChat_OnUiManagerInit() {
MelonCoroutines.Start(Setup());
}
/*
// Code from DDAkebono, it was a temporary replacement for VRChat_OnUiManagerInit
private static int scenesLoaded = 0;
public override void OnSceneWasLoaded(int buildIndex, string sceneName) {
scenesLoaded++;
if (scenesLoaded != 2) return;
MelonCoroutines.Start(Setup());
}*/
private SingleButton cameraMovementButton = null;
private IEnumerator Setup() {
var request = new UnityWebRequest("https://vrchat.nitro.moe/mods/versioncheck", "POST");
request.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes("{\"name\":\"" + ModBuildInfo.Name + "\",\"version\":\"" + ModBuildInfo.Version + "\"}"));
request.downloadHandler = new DownloadHandlerBuffer();
request.SetRequestHeader("Content-Type", "application/json");
//yield return request.SendWebRequest();
MelonLogger.Msg("Checking mod version...");
var asyncOperation = request.SendWebRequest();
// yield return doesn't work for now, so I had to change it to this.
while (!asyncOperation.isDone) {
yield return new WaitForEndOfFrame();
}
bool updated = true;
string latest = "";
if (!request.isNetworkError && !request.isHttpError) {
try {
var response = JsonConvert.DeserializeObject<VersionCheckResponse>(request.downloadHandler.text);
if (response.result == "OUTDATED") {
updated = false;
}
latest = response.latest;
} catch (Exception) {
MelonLogger.Error("Failed to check version!");
}
} else {
MelonLogger.Error("Failed to check version!");
}
MelonLogger.Msg(updated ? $"You're updated! Latest version: {latest}" : $"A new version of the mod ({latest}) has been found, please update.");
var quickMenu = VRCUtils.GetQuickMenu();
if (!updated) quickMenu.transform.Find("ShortcutMenu/CameraButton").GetComponentInChildren<Text>().text = "Camera\n<color=lime>Update\navailable!</color>";
var cameraMenu = quickMenu.transform.Find("CameraMenu");
var filtersMenu = UnityEngine.Object.Instantiate(cameraMenu, quickMenu.transform);
filtersMenu.name = "FiltersMenu";
var panoramaButton = cameraMenu.Find("Panorama");
panoramaButton.localPosition = SingleButton.getButtonPositionFor(-1, 0);
var vrChiveButton = cameraMenu.Find("VRChive");
vrChiveButton.localPosition = SingleButton.getButtonPositionFor(-1, 1);
var backButton = cameraMenu.Find("BackButton");
backButton.localPosition = SingleButton.getButtonPositionFor(4, 2);
var screenshotButton = cameraMenu.Find("Screenshot");
screenshotButton.localPosition = SingleButton.getButtonPositionFor(4, 1);
var qmBoxCollider = quickMenu.GetComponent<BoxCollider>();
// Thank you JanNyaa (Janni9009#1751) <3
if (qmBoxCollider.size.y < 3768) qmBoxCollider.size += new Vector3(0f, 840f, 0f);
quickMenu.transform.Find("QuickMenu_NewElements/_CONTEXT/QM_Context_ToolTip/_ToolTipPanel/Text").GetComponent<Text>().supportRichText = true;
var smoothCameraButton = cameraMenu.Find("SmoothFPVCamera");
smoothCameraButton.localPosition = SingleButton.getButtonPositionFor(0, 3);
var photoModeButton = cameraMenu.Find("PhotoMode");
photoModeButton.localPosition = SingleButton.getButtonPositionFor(1, 3);
var videoModeButton = cameraMenu.Find("VideoMode");
videoModeButton.localPosition = SingleButton.getButtonPositionFor(2, 3);
var disableCameraButton = cameraMenu.Find("DisableCamera");
disableCameraButton.localPosition = SingleButton.getButtonPositionFor(3, 3);
// "Create A Developer Light" the fuck even is this
var lightButton = cameraMenu.Find("Light");
lightButton.localPosition = SingleButton.getButtonPositionFor(4, 3);
var cameraButton = new SingleButton("Camera", "Camera\n<color=red>Off</color>", "Toggles the Camera", 0, 0, cameraMenu);
cameraButton.setAction((Action)(() => {
Settings.cameraEnabled = !Settings.cameraEnabled;
cameraButton.setText("Camera\n<color=" + (Settings.cameraEnabled ? "#ff73fa>On" : "red>Off") + "</color>");
CameraUtils.SetCameraMode(Settings.cameraEnabled ? CameraUtils.CameraMode.Photo : CameraUtils.CameraMode.Off);
}));
var movementBehaviourButton = new SingleButton("MovementBehaviour", "Movement\nBehaviour\n<color=#ff73fa>None</color>", "Cycles the Camera's movement behaviour", 1, 0, cameraMenu);
movementBehaviourButton.setAction((Action)(() => {
if (Settings.cameraEnabled) {
var cameraBehaviour = CameraUtils.GetCameraBehaviour();
string behaviour = "?";
switch (cameraBehaviour) {
case CameraUtils.CameraBehaviour.None:
behaviour = "Smooth";
break;
case CameraUtils.CameraBehaviour.Smooth:
behaviour = "Look At";
break;
case CameraUtils.CameraBehaviour.LookAt:
behaviour = "None";
break;
}
movementBehaviourButton.setText("Movement\nBehaviour\n<color=#ff73fa>" + behaviour + "</color>");
CameraUtils.CycleCameraBehaviour();
}
}));
var movementSpaceButton = new SingleButton("MovementSpace", "Movement\nSpace\n<color=#ff73fa>Attached</color>", "Cycles the Camera's movement space", 2, 0, cameraMenu);
movementSpaceButton.setAction((Action)(() => {
if (Settings.cameraEnabled) {
var cameraSpace = CameraUtils.GetCameraSpace();
string space = "?";
switch (cameraSpace) {
case CameraUtils.CameraSpace.Attached:
space = "Local";
break;
case CameraUtils.CameraSpace.Local:
space = "World";
break;
case CameraUtils.CameraSpace.World:
space = "Attached";
break;
}
movementSpaceButton.setText("Movement\nSpace\n<color=#ff73fa>" + space + "</color>");
CameraUtils.CycleCameraSpace();
if (CameraUtils.GetCameraSpace() == CameraUtils.CameraSpace.World) Settings.allowCameraMovement = true; else Settings.allowCameraMovement = false;
}
}));
var pinMenuButton = new SingleButton("PinMenu", "Pin Menu\n<color=red>Off</color>", "Toggles the Pin menu", 0, 1, cameraMenu);
pinMenuButton.setAction((Action)(() => {
if (Settings.cameraEnabled) {
CameraUtils.TogglePinMenu();
pinMenuButton.setText("Pin Menu\n<color=" + (CameraUtils.GetPinsHolder().activeSelf ? "#ff73fa>On" : "red>Off") + "</color>");
}
}));
var switchPinButton = new SingleButton("CyclePin", "Cycle Pin\n<color=#ff73fa>Pin 1</color>", "Cycles between 3 pins (aka profiles)", 1, 1, cameraMenu);
switchPinButton.setAction((Action)(() => {
if (Settings.cameraEnabled) {
var currentPin = CameraUtils.GetCurrentPin();
string pin = "?";
int newPin = 1;
switch (currentPin) {
case CameraUtils.Pin.Pin1:
newPin = 2;
pin = "Pin 2";
break;
case CameraUtils.Pin.Pin2:
newPin = 3;
pin = "Pin 3";
break;
case CameraUtils.Pin.Pin3:
newPin = 1;
pin = "Pin 1";
break;
}
switchPinButton.setText("Cycle Pin\n<color=#ff73fa>" + pin + "</color>");
// Needed to initialize the buttons apparently
CameraUtils.TogglePinMenu();
CameraUtils.TogglePinMenu();
CameraUtils.SetPin(newPin);
}
}));
var timer1Button = new SingleButton("Timer1", "Timer\n<color=#ff73fa>3s</color>", "Takes a picture after 3 seconds", 3, 0, cameraMenu);
timer1Button.setAction((Action)(() => {
if (Settings.cameraEnabled) {
CameraUtils.TakePicture(3);
}
}));
var timer2Button = new SingleButton("Timer2", "Timer\n<color=#ff73fa>5s</color>", "Takes a picture after 5 seconds", 3, 1, cameraMenu);
timer2Button.setAction((Action)(() => {
if (Settings.cameraEnabled) {
CameraUtils.TakePicture(5);
}
}));
var timer3Button = new SingleButton("Timer3", "Timer\n<color=#ff73fa>10s</color>", "Takes a picture after 10 seconds", 3, 2, cameraMenu);
timer3Button.setAction((Action)(() => {
if (Settings.cameraEnabled) {
CameraUtils.TakePicture(10);
}
}));
var cameraScaleButton = new SingleButton("CameraScale", "Camera\nScale\n<color=#ff73fa>Normal</color>", "Changes the Camera's scale", 2, 1, cameraMenu);
cameraScaleButton.setAction((Action)(() => {
if (Settings.cameraEnabled) {
string scale = "?";
switch (Settings.cameraScale) {
case CameraUtils.CameraScale.Normal:
scale = "Medium";
CameraUtils.GetViewFinder().transform.localScale = new Vector3(1.5f, 1f, 1.5f);
Settings.cameraScale = CameraUtils.CameraScale.Medium;
break;
case CameraUtils.CameraScale.Medium:
scale = "Big";
CameraUtils.GetViewFinder().transform.localScale = new Vector3(2f, 1f, 2f);
Settings.cameraScale = CameraUtils.CameraScale.Big;
break;
case CameraUtils.CameraScale.Big:
scale = "Normal";
CameraUtils.GetViewFinder().transform.localScale = new Vector3(1f, 1f, 1f);
Settings.cameraScale = CameraUtils.CameraScale.Normal;
break;
}
cameraScaleButton.setText("Camera\nScale\n<color=#ff73fa>" + scale + "</color>");
}
}));
var toggleArrowKeysButton = new SingleButton("ArrowKeys", "Arrow Keys\n<color=#ff73fa>On</color>", "Allows you to change the camera position\nand rotation using arrow keys and numpad keys\n<color=orange>(for more info check the GitHub page)</color>", 0, 2, cameraMenu);
toggleArrowKeysButton.setAction((Action)(() => {
Settings.arrowKeysEnabled = !Settings.arrowKeysEnabled;
toggleArrowKeysButton.setText("Arrow Keys\n<color=" + (Settings.arrowKeysEnabled ? "#ff73fa>On" : "red>Off") + "</color>");
}));
var rotateAroundUserCameraButton = new SingleButton("RotateAroundUserCamera", "Rotate\nAround\nUser Camera\n<color=red>Off</color>", "Makes the camera rotate around the user's camera\ninstead of just saying bye bye\n<color=orange>(for more info check the GitHub page)</color>", 1, 2, cameraMenu);
rotateAroundUserCameraButton.setAction((Action)(() => {
Settings.rotateAroundUserCamera = !Settings.rotateAroundUserCamera;
rotateAroundUserCameraButton.setText("Rotate\nAround\nUser Camera\n<color=" + (Settings.rotateAroundUserCamera ? "#ff73fa>On" : "red>Off") + "</color>");
}));
var toggleLockButton = new SingleButton("ToggleLock", "Lock\n<color=red>Off</color>", "Toggles the Lock (Camera pickup)", 4, -1, cameraMenu);
toggleLockButton.setAction((Action)(() => {
if (Settings.cameraEnabled) {
toggleLockButton.setText("Lock\n<color=" + (CameraUtils.GetViewFinder().GetComponent<VRC_Pickup>().pickupable ? "#ff73fa>On" : "red>Off") + "</color>");
CameraUtils.ToggleLock();
}
}));
var gitHubButton = new SingleButton("GitHubPage", "<color=#ff73fa>" + (updated ? "GitHub\nPage</color>" : "GitHub Page</color>\n<color=lime>Update\navailable!</color>"), "Opens the GitHub page of the mod\n<color=#ff73fa><size=20><b>Mod created by nitro. ♥</b></size></color>\nVersion: " + ModBuildInfo.Version + (updated ? "" : "\n<color=lime>New version found (" + latest + "), update it in the GitHub page.</color>"), -1, -1, cameraMenu);
gitHubButton.setAction((Action)(() => {
Application.OpenURL(updated ? "https://github.com/nitrog0d/DesktopCamera" : "https://github.com/nitrog0d/DesktopCamera/releases");
}));
var childCount = filtersMenu.transform.childCount;
for (var i = 0; i < childCount; i++) {
var child = filtersMenu.transform.GetChild(i);
if (child.name == "BackButton") {
child.localPosition = SingleButton.getButtonPositionFor(4, 2);
child.GetComponent<UiTooltip>().field_Public_String_0 = "Go Back to the Camera Menu";
child.GetComponent<Button>().onClick.RemoveAllListeners();
child.GetComponent<Button>().onClick.AddListener((Action)(() => {
VRCUtils.ShowQuickMenuPage(quickMenu, cameraMenu, "FiltersMenu");
}));
} else {
UnityEngine.Object.Destroy(child.gameObject);
}
}
var filters = new Dictionary<string, string>()
{
{ "<color=#ff73fa>None</color>", "button-NONE" },
{ "<color=#00a0ff>Blueprint</color>", "Button-Blueprint" },
{ "<color=#20c20e>Code</color>", "Button-Code" },
{ "<color=#ffee7b>Sparkles</color>", "Button-Sparkles" },
{ "<color=#00ff23>Green\nScreen</color>", "Button-GreenScreen" },
{ "<color=#ff0000>G</color><color=#00ff00>l</color><color=#0000ff>i</color><color=#ff0000>t</color><color=#00ff00>c</color><color=#0000ff>h</color>", "Button-Glitch" }, // Sorry
{ "<color=#cd853f>Old Timey</color>", "Button-OLD-TIMEY" },
{ "<color=#a9a9a9>Drawing</color>", "Button-Drawing" },
{ "<color=white><i>Trippy</i></color>", "Button-Trippy" },
{ "<color=#ffffffcc>Local\nAlpha</color>", "Button-LocalAlpha" },
{ "<color=#ffffffcc>Alpha\nTransparent</color>", "Button-ALPHA" },
{ "<color=white>Pixelate</color>", "Button-PIXELS" }
};
int row = 0;
int position = 0;
foreach (var filter in filters) {
var button = new SingleButton("Filter" + filter.Value, filter.Key, "Sets the filter to " + filter.Key.Replace("\n", " "), position, row, filtersMenu);
button.setAction((Action)(() => {
if (Settings.cameraEnabled) {
// Needed to initialize the buttons apparently
CameraUtils.ToggleFilterMenu();
CameraUtils.ToggleFilterMenu();
CameraUtils.SetFilter(filter.Value);
}
}));
position++;
if (position == 4) {
position = 0;
row++;
}
}
var filtersButton = new SingleButton("Filters", "Filters", "Opens the filter menu", 4, 0, cameraMenu);
filtersButton.setAction((Action)(() => {
VRCUtils.ShowQuickMenuPage(quickMenu, filtersMenu, cameraMenu.name);
}));
cameraMovementButton = new SingleButton("ToggleCameraMovement", "Camera\nMovement\n<color=#ff73fa>Viewer</color>", "Toggles the arrow/numpad keys movement between the actual Camera and the Viewer\nViewer requires Movement Space to be \"World\" <color=orange>(for more info check the GitHub page)</color>", 2, 2, cameraMenu);
cameraMovementButton.setAction((Action)(() => {
if (Settings.cameraEnabled) {
Settings.moveCamera = !Settings.moveCamera;
cameraMovementButton.setText("Camera\nMovement\n<color=#ff73fa>" + (Settings.moveCamera ? "Camera" : "Viewer") + "</color>");
}
}));
}
// This is a mess please don't look
// and also pull request to improve it thx
public override void OnUpdate() {
// Testing
/*if (Input.GetKeyDown(KeyCode.F1)) {
MelonLogger.Msg("test");
var viewFinder = CameraUtils.GetPinsHolder().transform.Find("button-Pin-1");
var components = viewFinder.GetComponents<Component>();
for (int i = 0; i < components.Length; i++) {
var component = components[i];
MelonLogger.Msg(i + " - " + component.name + " - " + component.GetIl2CppType().Name);
}
var childCount = viewFinder.transform.childCount;
for (int i = 0; i < childCount; i++) {
var child = viewFinder.transform.GetChild(i);
MelonLogger.Log(child.name + " - " + child.GetIl2CppType().Name);
}
}*/
if (Settings.cameraEnabled && Settings.arrowKeysEnabled) {
var cameraRotation = CameraUtils.worldCameraQuaternion.ToEuler();
var actualCameraSpeed = (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
? CameraSpeedAlt
: CameraSpeed;
if (Input.GetKey(KeyCode.DownArrow)) {
if (Settings.moveCamera) {
if (Settings.allowCameraMovement) {
if (Settings.rotateAroundUserCamera)
CameraUtils.RotateAround(VRCUtils.GetMainCamera().transform.position,
VRCUtils.GetMainCamera().transform.up,
(Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f);
else
CameraUtils.worldCameraVector -= new Vector3(
(float)Math.Sin(cameraRotation.y) * actualCameraSpeed, 0f,
(float)Math.Cos(cameraRotation.y) * actualCameraSpeed);
}
} else {
CameraUtils.GetViewFinder().transform.localPosition += new Vector3(0f, 0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -0.01f : -0.005f);
}
}
if (Input.GetKey(KeyCode.UpArrow)) {
if (Settings.moveCamera) {
if (Settings.allowCameraMovement) {
if (Settings.rotateAroundUserCamera) CameraUtils.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.up, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f);
else CameraUtils.worldCameraVector += new Vector3(
(float)Math.Sin(cameraRotation.y) * actualCameraSpeed, 0f,
(float)Math.Cos(cameraRotation.y) * actualCameraSpeed);
}
} else {
CameraUtils.GetViewFinder().transform.localPosition += new Vector3(0f, 0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 0.01f : 0.005f);
}
}
if (Input.GetKey(KeyCode.PageUp)) {
if (Settings.moveCamera) {
if (Settings.allowCameraMovement) {
if (Settings.rotateAroundUserCamera) CameraUtils.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.right, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f);
else CameraUtils.worldCameraVector += new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? CameraSpeedAlt : CameraSpeed, 0f);
}
} else {
if (Settings.rotateAroundUserCamera) CameraUtils.GetViewFinder().transform.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.right, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f);
else CameraUtils.GetViewFinder().transform.localPosition += new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 0.01f : 0.005f, 0f);
}
}
if (Input.GetKey(KeyCode.PageDown)) {
if (Settings.moveCamera) {
if (Settings.allowCameraMovement) {
if (Settings.rotateAroundUserCamera) CameraUtils.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.right, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f);
else CameraUtils.worldCameraVector += new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -CameraSpeedAlt : -CameraSpeed, 0f);
}
} else {
if (Settings.rotateAroundUserCamera) CameraUtils.GetViewFinder().transform.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.right, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f);
else CameraUtils.GetViewFinder().transform.localPosition += new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -0.01f : -0.005f, 0f);
}
}
if (Input.GetKey(KeyCode.LeftArrow)) {
if (Settings.moveCamera) {
if (Settings.allowCameraMovement) CameraUtils.worldCameraVector -= new Vector3(
(float)Math.Cos(cameraRotation.y) * actualCameraSpeed, 0f,
(float)-Math.Sin(cameraRotation.y) * actualCameraSpeed);
} else {
if (Settings.rotateAroundUserCamera) CameraUtils.GetViewFinder().transform.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.up, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f);
else CameraUtils.GetViewFinder().transform.localPosition += new Vector3((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -0.01f : -0.005f, 0f, 0f);
}
}
if (Input.GetKey(KeyCode.RightArrow)) {
if (Settings.moveCamera) {
if (Settings.allowCameraMovement) CameraUtils.worldCameraVector += new Vector3(
(float)Math.Cos(cameraRotation.y) * actualCameraSpeed, 0f,
(float)-Math.Sin(cameraRotation.y) * actualCameraSpeed);
} else {
if (Settings.rotateAroundUserCamera) CameraUtils.GetViewFinder().transform.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.up, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f);
else CameraUtils.GetViewFinder().transform.localPosition += new Vector3((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 0.01f : 0.005f, 0f, 0f);
}
}
// Rotation
if (Input.GetKey(KeyCode.Keypad8)) {
if (Settings.moveCamera) {
if (Settings.allowCameraMovement) CameraUtils.worldCameraQuaternion *= Quaternion.Euler(Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? -2f : -1f, 0f, 0f);
} else {
CameraUtils.GetViewFinder().transform.Rotate(new Vector3((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f, 0f));
}
}
if (Input.GetKey(KeyCode.Keypad2)) {
if (Settings.moveCamera) {
if (Settings.allowCameraMovement) CameraUtils.worldCameraQuaternion *= Quaternion.Euler(Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? 2f : 1f, 0f, 0f);
} else {
CameraUtils.GetViewFinder().transform.Rotate(new Vector3((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f, 0f));
}
}
if (Input.GetKey(KeyCode.Keypad4)) {
if (Settings.moveCamera) {
if (Settings.allowCameraMovement) CameraUtils.worldCameraQuaternion *= Quaternion.Euler(0f, Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? -2f : -1f, 0f);
} else {
CameraUtils.GetViewFinder().transform.Rotate(new Vector3(0f, 0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f));
}
}
if (Input.GetKey(KeyCode.Keypad6)) {
if (Settings.moveCamera) {
if (Settings.allowCameraMovement) CameraUtils.worldCameraQuaternion *= Quaternion.Euler(0f, Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? 2f : 1f, 0f);
} else {
CameraUtils.GetViewFinder().transform.Rotate(new Vector3(0f, 0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f));
}
}
if (Input.GetKey(KeyCode.Keypad7)) {
if (Settings.moveCamera) {
if (Settings.allowCameraMovement) CameraUtils.worldCameraQuaternion *= Quaternion.Euler(0f, 0f, Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? 2f : 1f);
} else {
CameraUtils.GetViewFinder().transform.Rotate(new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f, 0f));
}
}
if (Input.GetKey(KeyCode.Keypad9)) {
if (Settings.moveCamera) {
if (Settings.allowCameraMovement) CameraUtils.worldCameraQuaternion *= Quaternion.Euler(0f, 0f, Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? -2f : -1f);
} else {
CameraUtils.GetViewFinder().transform.Rotate(new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f, 0f));
}
}
// Reset
if (Input.GetKeyDown(KeyCode.Keypad3)) {
if (Settings.cameraEnabled) CameraUtils.ResetCamera();
}
// Look at player
if (Input.GetKeyDown(KeyCode.Keypad1)) {
if (Settings.cameraEnabled) {
CameraUtils.GetViewFinder().transform.LookAt(VRCUtils.GetMainCamera().transform);
CameraUtils.GetViewFinder().transform.rotation *= Quaternion.Euler(90f, 0f, 0f);
}
}
// Take pic
if (Input.GetKeyDown(KeyCode.KeypadPlus)) {
if (Settings.cameraEnabled) CameraUtils.TakePicture(0);
}
// Toggle camera movement
if (Input.GetKeyDown(KeyCode.KeypadMinus)) {
if (Settings.cameraEnabled) {
if (cameraMovementButton != null) {
Settings.moveCamera = !Settings.moveCamera;
cameraMovementButton.setText("Camera\nMovement\n<color=#ff73fa>" + (Settings.moveCamera ? "Camera" : "Viewer") + "</color>");
VRCUtils.QueueHudMessage("Camera Movement set to " + (Settings.moveCamera ? "Camera" : "Viewer"));
}
}
}
}
}
}
}