-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[F] Refactor CustomCameraId and remove hard-coded enums / IDs (#71)
* refactor * Add PrintCameraList check * Separate PrintCameraList to a class * cleanup
- Loading branch information
Showing
2 changed files
with
82 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using MelonLoader; | ||
using UnityEngine; | ||
|
||
namespace AquaMai.CustomCameraId; | ||
|
||
public class PrintCameraList | ||
{ | ||
public static void DoCustomPatch(HarmonyLib.Harmony _) | ||
{ | ||
WebCamDevice[] devices = WebCamTexture.devices; | ||
string cameraList = "Connected Web Cameras:\n"; | ||
for (int i = 0; i < devices.Length; i++) | ||
{ | ||
WebCamDevice webCamDevice = devices[i]; | ||
WebCamTexture webCamTexture = new WebCamTexture(webCamDevice.name); | ||
webCamTexture.Play(); | ||
cameraList += "==================================================\n"; | ||
cameraList += "Name: " + webCamDevice.name + "\n"; | ||
cameraList += $"ID: {i}\n"; | ||
cameraList += $"Resolution: {webCamTexture.width} * {webCamTexture.height}\n"; | ||
cameraList += $"FPS: {webCamTexture.requestedFPS}\n"; | ||
webCamTexture.Stop(); | ||
} | ||
cameraList += "=================================================="; | ||
|
||
foreach (var line in cameraList.Split('\n')) | ||
{ | ||
MelonLogger.Msg($"[CustomCameraId] {line}"); | ||
} | ||
} | ||
} |