mirror of
https://github.com/MrUnknownDE/vcc-tools.git
synced 2026-05-07 15:36:05 +02:00
Compare commits
8 Commits
9250fc71ed
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a3eb6cf71f | |||
| a3a23902ab | |||
| e89eb856ca | |||
| 689ceca124 | |||
| 185f1cc96a | |||
| 32a428502d | |||
| 50017d40c8 | |||
| 5490b72e5d |
@@ -0,0 +1,64 @@
|
|||||||
|
using UdonSharp;
|
||||||
|
using UnityEngine;
|
||||||
|
using AudioLink;
|
||||||
|
|
||||||
|
public class AudioLinkBeatDetector : UdonSharpBehaviour
|
||||||
|
{
|
||||||
|
public AudioLink.AudioLink audioLinkInstance;
|
||||||
|
|
||||||
|
[Header("Settings")]
|
||||||
|
[Range(0, 1)] public float threshold = 0.5f;
|
||||||
|
public float minBpm = 70f;
|
||||||
|
public float maxBpm = 210f; // Alles darüber wird als Fehler ignoriert
|
||||||
|
|
||||||
|
[Header("Output")]
|
||||||
|
public float bpm = 128f;
|
||||||
|
public float instantBpm = 128f;
|
||||||
|
public bool isBeat;
|
||||||
|
|
||||||
|
private float lastBeatTime;
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (audioLinkInstance == null || !audioLinkInstance.AudioDataIsAvailable()) return;
|
||||||
|
|
||||||
|
Vector2 bassPos = AudioLink.AudioLink.GetALPassAudioBass();
|
||||||
|
Vector4 data = audioLinkInstance.GetDataAtPixel((int)bassPos.x, (int)bassPos.y);
|
||||||
|
float currentLevel = data.x;
|
||||||
|
|
||||||
|
// Prüfen auf Threshold
|
||||||
|
if (currentLevel > threshold)
|
||||||
|
{
|
||||||
|
float currentTime = Time.time;
|
||||||
|
float timeDiff = currentTime - lastBeatTime;
|
||||||
|
|
||||||
|
// Der "Debounce" Check:
|
||||||
|
// 0.27s entspricht ca. 222 BPM. Alles was schneller kommt, ist Rauschen.
|
||||||
|
if (timeDiff > 0.27f)
|
||||||
|
{
|
||||||
|
if (lastBeatTime > 0)
|
||||||
|
{
|
||||||
|
float detected = 60f / timeDiff;
|
||||||
|
|
||||||
|
// Nur plausible Werte übernehmen
|
||||||
|
if (detected >= minBpm && detected <= maxBpm)
|
||||||
|
{
|
||||||
|
instantBpm = detected;
|
||||||
|
// Glättung: 0.5 sorgt für schnelles Folgen, aber filtert Ausreißer
|
||||||
|
bpm = Mathf.Lerp(bpm, instantBpm, 0.5f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastBeatTime = currentTime;
|
||||||
|
isBeat = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isBeat = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isBeat = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
using UdonSharp;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using TMPro;
|
||||||
|
|
||||||
|
public class BeatDetectorDisplay : UdonSharpBehaviour
|
||||||
|
{
|
||||||
|
public AudioLinkBeatDetector engine;
|
||||||
|
public TextMeshProUGUI bpmText;
|
||||||
|
public Image beatIndicator;
|
||||||
|
public Color activeColor = Color.cyan;
|
||||||
|
|
||||||
|
private float flashTimer;
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (engine == null) return;
|
||||||
|
|
||||||
|
// Wenn die Engine einen Beat erkennt...
|
||||||
|
if (engine.isBeat)
|
||||||
|
{
|
||||||
|
// ...aktualisieren wir SOFORT den Text mit der instantBpm
|
||||||
|
if (bpmText != null)
|
||||||
|
{
|
||||||
|
bpmText.text = engine.instantBpm.ToString("F0"); // "F0" für ganze Zahlen ohne Lag-Gefühl
|
||||||
|
}
|
||||||
|
|
||||||
|
// Visueller Kick
|
||||||
|
flashTimer = 0.1f;
|
||||||
|
if (beatIndicator != null) beatIndicator.color = activeColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Timer für das Abklingen der LED
|
||||||
|
if (flashTimer > 0)
|
||||||
|
{
|
||||||
|
flashTimer -= Time.deltaTime;
|
||||||
|
if (flashTimer <= 0 && beatIndicator != null)
|
||||||
|
{
|
||||||
|
beatIndicator.color = new Color(0.1f, 0.1f, 0.1f, 1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+136
-47
@@ -35,6 +35,11 @@ public class GitPanel : EditorWindow
|
|||||||
private string webUrlOverride = "";
|
private string webUrlOverride = "";
|
||||||
private string prefsKey = "";
|
private string prefsKey = "";
|
||||||
|
|
||||||
|
private double lastRefreshTime = -999;
|
||||||
|
|
||||||
|
private bool isLoading = false;
|
||||||
|
private string loadingMessage = "";
|
||||||
|
|
||||||
private struct CommitInfo { public string hash; public string date; public string message; }
|
private struct CommitInfo { public string hash; public string date; public string message; }
|
||||||
private List<CommitInfo> commitHistory = new List<CommitInfo>();
|
private List<CommitInfo> commitHistory = new List<CommitInfo>();
|
||||||
|
|
||||||
@@ -47,15 +52,51 @@ public class GitPanel : EditorWindow
|
|||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
|
EditorApplication.update += OnEditorUpdate;
|
||||||
prefsKey = $"GitTool_WebUrl_{Application.dataPath.GetHashCode()}";
|
prefsKey = $"GitTool_WebUrl_{Application.dataPath.GetHashCode()}";
|
||||||
webUrlOverride = EditorPrefs.GetString(prefsKey, "");
|
webUrlOverride = EditorPrefs.GetString(prefsKey, "");
|
||||||
RefreshData();
|
RefreshData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFocus() { RefreshData(); }
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
EditorApplication.update -= OnEditorUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEditorUpdate()
|
||||||
|
{
|
||||||
|
if (isLoading) Repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RunNetworkCommand(string message, System.Func<string> work, System.Action<string> onDone)
|
||||||
|
{
|
||||||
|
if (isLoading) return;
|
||||||
|
isLoading = true;
|
||||||
|
loadingMessage = message;
|
||||||
|
Repaint();
|
||||||
|
System.Threading.ThreadPool.QueueUserWorkItem(_ =>
|
||||||
|
{
|
||||||
|
string result = work();
|
||||||
|
EditorApplication.delayCall += () =>
|
||||||
|
{
|
||||||
|
isLoading = false;
|
||||||
|
loadingMessage = "";
|
||||||
|
onDone(result);
|
||||||
|
Repaint();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnFocus()
|
||||||
|
{
|
||||||
|
if (EditorApplication.timeSinceStartup - lastRefreshTime > 2.0)
|
||||||
|
RefreshData();
|
||||||
|
}
|
||||||
|
|
||||||
public void RefreshData()
|
public void RefreshData()
|
||||||
{
|
{
|
||||||
|
lastRefreshTime = EditorApplication.timeSinceStartup;
|
||||||
|
|
||||||
CheckGitInstallation();
|
CheckGitInstallation();
|
||||||
CheckUnitySettings();
|
CheckUnitySettings();
|
||||||
|
|
||||||
@@ -64,7 +105,6 @@ public class GitPanel : EditorWindow
|
|||||||
|
|
||||||
if (hasRepo)
|
if (hasRepo)
|
||||||
{
|
{
|
||||||
ExportPackageInventory();
|
|
||||||
currentBranchName = RunGitCommand("rev-parse --abbrev-ref HEAD").Trim();
|
currentBranchName = RunGitCommand("rev-parse --abbrev-ref HEAD").Trim();
|
||||||
FetchBranches();
|
FetchBranches();
|
||||||
}
|
}
|
||||||
@@ -116,6 +156,21 @@ public class GitPanel : EditorWindow
|
|||||||
|
|
||||||
private void OnGUI()
|
private void OnGUI()
|
||||||
{
|
{
|
||||||
|
if (isLoading)
|
||||||
|
{
|
||||||
|
EditorGUI.DrawRect(new Rect(0, 0, position.width, position.height), new Color(0.15f, 0.15f, 0.15f, 1f));
|
||||||
|
string[] frames = { "|", "/", "-", "\\" };
|
||||||
|
string spinner = frames[(int)(EditorApplication.timeSinceStartup * 8) % 4];
|
||||||
|
GUIStyle style = new GUIStyle(EditorStyles.boldLabel)
|
||||||
|
{
|
||||||
|
alignment = TextAnchor.MiddleCenter,
|
||||||
|
fontSize = 13,
|
||||||
|
normal = { textColor = Color.white }
|
||||||
|
};
|
||||||
|
GUI.Label(new Rect(0, position.height / 2 - 20, position.width, 40), $"{spinner} {loadingMessage}", style);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GUILayout.Space(10);
|
GUILayout.Space(10);
|
||||||
GUILayout.Label("GIT Version Control System", EditorStyles.boldLabel);
|
GUILayout.Label("GIT Version Control System", EditorStyles.boldLabel);
|
||||||
if (hasRepo) GUILayout.Label($"Active Branch: {currentBranchName}", EditorStyles.miniLabel);
|
if (hasRepo) GUILayout.Label($"Active Branch: {currentBranchName}", EditorStyles.miniLabel);
|
||||||
@@ -138,7 +193,7 @@ public class GitPanel : EditorWindow
|
|||||||
if (!isGitInstalled) { RenderGitMissingUI(); return; }
|
if (!isGitInstalled) { RenderGitMissingUI(); return; }
|
||||||
if (!hasRepo) { RenderInitUI(); return; }
|
if (!hasRepo) { RenderInitUI(); return; }
|
||||||
|
|
||||||
showSettings = EditorGUILayout.Foldout(showSettings, "⚙️ Repository Settings");
|
showSettings = EditorGUILayout.Foldout(showSettings, "Repository Settings");
|
||||||
if (showSettings)
|
if (showSettings)
|
||||||
{
|
{
|
||||||
EditorGUILayout.BeginVertical("box");
|
EditorGUILayout.BeginVertical("box");
|
||||||
@@ -152,7 +207,7 @@ public class GitPanel : EditorWindow
|
|||||||
|
|
||||||
GUILayout.Space(10);
|
GUILayout.Space(10);
|
||||||
GUILayout.Label("Inventory Management", EditorStyles.miniBoldLabel);
|
GUILayout.Label("Inventory Management", EditorStyles.miniBoldLabel);
|
||||||
if (GUILayout.Button("📄 Sync Package Inventory (Unity & VRChat)", GUILayout.Height(25)))
|
if (GUILayout.Button("Sync Package Inventory (Unity & VRChat)", GUILayout.Height(25)))
|
||||||
{
|
{
|
||||||
ExportPackageInventory();
|
ExportPackageInventory();
|
||||||
}
|
}
|
||||||
@@ -238,26 +293,31 @@ public class GitPanel : EditorWindow
|
|||||||
GUI.backgroundColor = new Color(0.2f, 0.4f, 0.8f);
|
GUI.backgroundColor = new Color(0.2f, 0.4f, 0.8f);
|
||||||
if (GUILayout.Button("✓ Push", GUILayout.Height(30)))
|
if (GUILayout.Button("✓ Push", GUILayout.Height(30)))
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log("Git-Tool: Saving Scenes and Assets before push...");
|
// Unity APIs must stay on the main thread
|
||||||
UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes();
|
UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes();
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(commitMessage)) SetDefaultCommitMessage();
|
if (string.IsNullOrWhiteSpace(commitMessage)) SetDefaultCommitMessage();
|
||||||
RunGitCommand("add .", true);
|
string msgSnapshot = commitMessage;
|
||||||
RunGitCommand($"commit -m \"{commitMessage}\"", true);
|
|
||||||
|
|
||||||
string pushResult = RunGitCommand("push -u origin HEAD", true);
|
RunNetworkCommand("Committing and pushing... (a browser window may open for authentication)",
|
||||||
if (pushResult.Contains("rejected") || pushResult.Contains("fetch first"))
|
() =>
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError("Git-Tool: PUSH REJECTED! Jemand anderes hat Änderungen hochgeladen. Bitte klicke zuerst auf 'Pull'.");
|
ExportPackageInventory();
|
||||||
}
|
RunGitCommand("add .", true);
|
||||||
|
RunGitCommand($"commit -m \"{msgSnapshot}\"", true);
|
||||||
|
return RunGitCommand("push -u origin HEAD", true, 180000);
|
||||||
|
},
|
||||||
|
result =>
|
||||||
|
{
|
||||||
|
if (result.Contains("rejected") || result.Contains("fetch first"))
|
||||||
|
UnityEngine.Debug.LogError("Git-Tool: PUSH REJECTED! Someone else pushed changes. Please click 'Pull' first.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log("Git-Tool: Changes successfully pushed!");
|
UnityEngine.Debug.Log("Git-Tool: Changes successfully pushed!");
|
||||||
commitMessage = "";
|
commitMessage = "";
|
||||||
}
|
}
|
||||||
LiveSyncPanel.BroadcastGitUpdate();
|
|
||||||
RefreshData();
|
RefreshData();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI.backgroundColor = new Color(0.8f, 0.6f, 0.2f);
|
GUI.backgroundColor = new Color(0.8f, 0.6f, 0.2f);
|
||||||
@@ -266,15 +326,18 @@ public class GitPanel : EditorWindow
|
|||||||
UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes();
|
UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes();
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
|
|
||||||
string pullResult = RunGitCommand("pull", true);
|
RunNetworkCommand("Pulling from remote... (a browser window may open for authentication)",
|
||||||
AssetDatabase.Refresh();
|
() => RunGitCommand("pull", true, 180000),
|
||||||
|
result =>
|
||||||
if (pullResult.Contains("CONFLICT"))
|
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError("Git-Tool: MERGE CONFLICT! Bitte in VS Code auflösen!");
|
AssetDatabase.Refresh();
|
||||||
EditorUtility.DisplayDialog("Merge Conflict", "Es gibt Konflikte mit den Server-Daten!\n\nGit konnte die Änderungen nicht automatisch zusammenführen. Bitte öffne die roten Dateien in deinem Code-Editor und löse den Konflikt manuell auf.", "OK");
|
if (result.Contains("CONFLICT"))
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogError("Git-Tool: MERGE CONFLICT! Please resolve conflicts in your code editor.");
|
||||||
|
EditorUtility.DisplayDialog("Merge Conflict", "There are conflicts with the remote changes.\n\nGit could not merge automatically. Please open the conflicting files in your code editor and resolve them manually.", "OK");
|
||||||
}
|
}
|
||||||
RefreshData();
|
RefreshData();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI.backgroundColor = new Color(0.8f, 0.3f, 0.3f);
|
GUI.backgroundColor = new Color(0.8f, 0.3f, 0.3f);
|
||||||
@@ -439,9 +502,9 @@ public class GitPanel : EditorWindow
|
|||||||
try {
|
try {
|
||||||
File.WriteAllLines(outputPath, mdLines, System.Text.Encoding.UTF8);
|
File.WriteAllLines(outputPath, mdLines, System.Text.Encoding.UTF8);
|
||||||
RunGitCommand($"add \"{outputPath}\"");
|
RunGitCommand($"add \"{outputPath}\"");
|
||||||
UnityEngine.Debug.Log($"Git-Tool: PACKAGES.md aktualisiert. {totalFound} Einträge gefunden.");
|
UnityEngine.Debug.Log($"Git-Tool: PACKAGES.md updated. {totalFound} entries found.");
|
||||||
} catch (System.Exception e) {
|
} catch (System.Exception e) {
|
||||||
UnityEngine.Debug.LogError("Git-Tool: Fehler beim Schreiben der PACKAGES.md: " + e.Message);
|
UnityEngine.Debug.LogError("Git-Tool: Failed to write PACKAGES.md: " + e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,22 +516,21 @@ public class GitPanel : EditorWindow
|
|||||||
try {
|
try {
|
||||||
string content = File.ReadAllText(path);
|
string content = File.ReadAllText(path);
|
||||||
|
|
||||||
// 1. Finde den Start des "dependencies" Blocks
|
// 1. Find the start of the "dependencies" block
|
||||||
int startIndex = content.IndexOf("\"dependencies\"");
|
int startIndex = content.IndexOf("\"dependencies\"");
|
||||||
if (startIndex == -1) return 0;
|
if (startIndex == -1) return 0;
|
||||||
|
|
||||||
// Finde die erste öffnende Klammer nach dem Wort
|
// Find the first opening brace after the key
|
||||||
startIndex = content.IndexOf("{", startIndex);
|
startIndex = content.IndexOf("{", startIndex);
|
||||||
if (startIndex == -1) return 0;
|
if (startIndex == -1) return 0;
|
||||||
|
|
||||||
// 2. Extrahiere exakt diesen Block, indem wir Klammern zählen
|
// 2. Extract exactly this block by counting braces
|
||||||
int openBraces = 0;
|
int openBraces = 0;
|
||||||
int endIndex = startIndex;
|
int endIndex = startIndex;
|
||||||
for (int i = startIndex; i < content.Length; i++) {
|
for (int i = startIndex; i < content.Length; i++) {
|
||||||
if (content[i] == '{') openBraces++;
|
if (content[i] == '{') openBraces++;
|
||||||
if (content[i] == '}') {
|
if (content[i] == '}') {
|
||||||
openBraces--;
|
openBraces--;
|
||||||
// Sobald wir wieder bei 0 sind, ist der Dependencies-Block geschlossen
|
|
||||||
if (openBraces == 0) {
|
if (openBraces == 0) {
|
||||||
endIndex = i;
|
endIndex = i;
|
||||||
break;
|
break;
|
||||||
@@ -478,22 +540,19 @@ public class GitPanel : EditorWindow
|
|||||||
|
|
||||||
if (endIndex <= startIndex) return 0;
|
if (endIndex <= startIndex) return 0;
|
||||||
|
|
||||||
// Header nur zeichnen, wenn wir wirklich einen Block haben
|
|
||||||
outputList.Add($"## {sectionTitle}");
|
outputList.Add($"## {sectionTitle}");
|
||||||
outputList.Add("| Package Name | Version / Source |");
|
outputList.Add("| Package Name | Version / Source |");
|
||||||
outputList.Add("| :--- | :--- |");
|
outputList.Add("| :--- | :--- |");
|
||||||
|
|
||||||
// Den isolierten Block herauslösen und in Zeilen splitten
|
// 3. Parse the isolated block line by line
|
||||||
string dependenciesBlock = content.Substring(startIndex, endIndex - startIndex + 1);
|
string dependenciesBlock = content.Substring(startIndex, endIndex - startIndex + 1);
|
||||||
string[] blockLines = dependenciesBlock.Split(new[] { '\r', '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
|
string[] blockLines = dependenciesBlock.Split(new[] { '\r', '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
string currentVpmPackage = "";
|
string currentVpmPackage = "";
|
||||||
|
|
||||||
// 3. Den sauberen Block auswerten
|
|
||||||
foreach (string line in blockLines) {
|
foreach (string line in blockLines) {
|
||||||
string trimmed = line.Trim();
|
string trimmed = line.Trim();
|
||||||
|
|
||||||
// Einzelne Klammern können wir ignorieren, da wir eh schon im richtigen Block sind
|
|
||||||
if (trimmed == "{" || trimmed == "}" || trimmed == "},") continue;
|
if (trimmed == "{" || trimmed == "}" || trimmed == "},") continue;
|
||||||
|
|
||||||
if (trimmed.StartsWith("\"")) {
|
if (trimmed.StartsWith("\"")) {
|
||||||
@@ -503,11 +562,11 @@ public class GitPanel : EditorWindow
|
|||||||
string rawValue = parts[1].Trim();
|
string rawValue = parts[1].Trim();
|
||||||
|
|
||||||
if (rawValue.StartsWith("{")) {
|
if (rawValue.StartsWith("{")) {
|
||||||
// VPM Paket Start (z.B. "com.vrchat.base": { )
|
// VPM package start, e.g. "com.vrchat.base": {
|
||||||
currentVpmPackage = key;
|
currentVpmPackage = key;
|
||||||
}
|
}
|
||||||
else if (key == "version") {
|
else if (key == "version") {
|
||||||
// VPM Paket Version (z.B. "version": "3.10.2")
|
// VPM package version, e.g. "version": "3.10.2"
|
||||||
string val = rawValue.Replace("\"", "").Replace(",", "").Trim();
|
string val = rawValue.Replace("\"", "").Replace(",", "").Trim();
|
||||||
if (!string.IsNullOrEmpty(currentVpmPackage)) {
|
if (!string.IsNullOrEmpty(currentVpmPackage)) {
|
||||||
outputList.Add($"| `{currentVpmPackage}` | {val} |");
|
outputList.Add($"| `{currentVpmPackage}` | {val} |");
|
||||||
@@ -516,7 +575,7 @@ public class GitPanel : EditorWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!rawValue.StartsWith("{")) {
|
else if (!rawValue.StartsWith("{")) {
|
||||||
// Unity Flat Paket (z.B. "com.unity.timeline": "1.2.3")
|
// Flat Unity package, e.g. "com.unity.timeline": "1.2.3"
|
||||||
string val = rawValue.Replace("\"", "").Replace(",", "").Trim();
|
string val = rawValue.Replace("\"", "").Replace(",", "").Trim();
|
||||||
outputList.Add($"| `{key}` | {val} |");
|
outputList.Add($"| `{key}` | {val} |");
|
||||||
count++;
|
count++;
|
||||||
@@ -525,46 +584,76 @@ public class GitPanel : EditorWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (System.Exception e) {
|
} catch (System.Exception e) {
|
||||||
UnityEngine.Debug.LogWarning($"Git-Tool: Warnung beim Lesen von {Path.GetFileName(path)}: {e.Message}");
|
UnityEngine.Debug.LogWarning($"Git-Tool: Could not read {Path.GetFileName(path)}: {e.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
outputList.Add("| - | No entries found |");
|
outputList.Add("| - | No entries found |");
|
||||||
}
|
}
|
||||||
|
|
||||||
outputList.Add(""); // Leerzeile für sauberes Markdown
|
outputList.Add("");
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIX: Methode ist wieder static!
|
public static string RunGitCommand(string args, bool logAction = false, int timeoutMs = 10000)
|
||||||
public static string RunGitCommand(string args, bool logAction = false) {
|
{
|
||||||
try {
|
try
|
||||||
ProcessStartInfo si = new ProcessStartInfo("git", args) {
|
{
|
||||||
|
ProcessStartInfo si = new ProcessStartInfo("git", args)
|
||||||
|
{
|
||||||
WorkingDirectory = Path.GetFullPath(Path.Combine(Application.dataPath, "..")),
|
WorkingDirectory = Path.GetFullPath(Path.Combine(Application.dataPath, "..")),
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
RedirectStandardError = true,
|
RedirectStandardError = true,
|
||||||
CreateNoWindow = true
|
CreateNoWindow = true
|
||||||
};
|
};
|
||||||
|
// Block stdin prompts (no TTY in Unity), but force GCM to use browser/GUI auth
|
||||||
|
si.EnvironmentVariables["GIT_TERMINAL_PROMPT"] = "0";
|
||||||
|
si.EnvironmentVariables["GCM_INTERACTIVE"] = "always";
|
||||||
|
si.EnvironmentVariables["GIT_SSH_COMMAND"] = "ssh -o BatchMode=yes -o ConnectTimeout=15";
|
||||||
|
|
||||||
using (Process p = Process.Start(si)) {
|
var stdout = new System.Text.StringBuilder();
|
||||||
string o = p.StandardOutput.ReadToEnd();
|
var stderr = new System.Text.StringBuilder();
|
||||||
string e = p.StandardError.ReadToEnd();
|
|
||||||
|
using (Process p = Process.Start(si))
|
||||||
|
{
|
||||||
|
// Async reading prevents the stdout/stderr pipe-buffer deadlock
|
||||||
|
p.OutputDataReceived += (_, e) => { if (e.Data != null) stdout.AppendLine(e.Data); };
|
||||||
|
p.ErrorDataReceived += (_, e) => { if (e.Data != null) stderr.AppendLine(e.Data); };
|
||||||
|
p.BeginOutputReadLine();
|
||||||
|
p.BeginErrorReadLine();
|
||||||
|
|
||||||
|
bool finished = p.WaitForExit(timeoutMs);
|
||||||
|
if (!finished)
|
||||||
|
{
|
||||||
|
p.Kill();
|
||||||
|
p.WaitForExit();
|
||||||
|
string timeoutNote = $"[{System.DateTime.Now:HH:mm:ss}] > git {args}\n⚠ TIMEOUT after {timeoutMs / 1000}s\n\n";
|
||||||
|
UnityEngine.Debug.LogWarning($"Git-Tool: Command timed out ({timeoutMs / 1000}s): git {args}");
|
||||||
|
if (logAction) gitLogOutput = timeoutNote + gitLogOutput;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
// Second WaitForExit (no timeout) flushes async output handlers
|
||||||
p.WaitForExit();
|
p.WaitForExit();
|
||||||
string result = o + (string.IsNullOrWhiteSpace(e) ? "" : "\n" + e);
|
|
||||||
|
|
||||||
if (logAction) {
|
string result = stdout.ToString() + (stderr.Length > 0 ? "\n" + stderr : "");
|
||||||
string time = System.DateTime.Now.ToString("HH:mm:ss");
|
|
||||||
string entry = $"[{time}] > git {args}\n";
|
if (logAction)
|
||||||
|
{
|
||||||
|
string entry = $"[{System.DateTime.Now:HH:mm:ss}] > git {args}\n";
|
||||||
if (!string.IsNullOrWhiteSpace(result)) entry += result.Trim() + "\n\n";
|
if (!string.IsNullOrWhiteSpace(result)) entry += result.Trim() + "\n\n";
|
||||||
|
|
||||||
gitLogOutput = entry + gitLogOutput;
|
gitLogOutput = entry + gitLogOutput;
|
||||||
if (gitLogOutput.Length > 10000) gitLogOutput = gitLogOutput.Substring(0, 10000);
|
if (gitLogOutput.Length > 10000) gitLogOutput = gitLogOutput.Substring(0, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} catch { return ""; }
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogWarning($"Git-Tool: Exception running git {args}: {ex.Message}");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,218 +0,0 @@
|
|||||||
using UnityEditor;
|
|
||||||
using UnityEngine;
|
|
||||||
using System;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Net.WebSockets;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
public class LiveSyncPanel : EditorWindow
|
|
||||||
{
|
|
||||||
private string wsUrl = "ws://localhost:8080";
|
|
||||||
private static ClientWebSocket ws;
|
|
||||||
private static bool isConnected = false;
|
|
||||||
private static CancellationTokenSource cts;
|
|
||||||
|
|
||||||
private Transform lastSelected;
|
|
||||||
private bool isNetworkApplying = false;
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
private class SyncMessage
|
|
||||||
{
|
|
||||||
public string type;
|
|
||||||
public string objectName;
|
|
||||||
public Vector3 position;
|
|
||||||
public Vector3 eulerAngles;
|
|
||||||
public Vector3 localScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
[MenuItem("Tools/MrUnknownDE/Live Sync Bridge")]
|
|
||||||
public static void ShowWindow()
|
|
||||||
{
|
|
||||||
GetWindow<LiveSyncPanel>("Live Sync Bridge").minSize = new Vector2(320, 350);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEnable()
|
|
||||||
{
|
|
||||||
wsUrl = EditorPrefs.GetString("LiveSync_WS_URL", "ws://localhost:8080");
|
|
||||||
EditorApplication.update += EditorUpdate;
|
|
||||||
Selection.selectionChanged += OnSelectionChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDisable()
|
|
||||||
{
|
|
||||||
EditorApplication.update -= EditorUpdate;
|
|
||||||
Selection.selectionChanged -= OnSelectionChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnGUI()
|
|
||||||
{
|
|
||||||
GUILayout.Space(5);
|
|
||||||
|
|
||||||
// --- 🚧 DICK & FETT: WIP WARNING 🚧 ---
|
|
||||||
EditorGUILayout.HelpBox(
|
|
||||||
"🚧 WORK IN PROGRESS 🚧\n\n" +
|
|
||||||
"This feature is highly experimental and in active development!\n" +
|
|
||||||
"Expect bugs, network desyncs, or unexpected behavior.\n\n" +
|
|
||||||
"ALWAYS backup your project before starting a Live Session!",
|
|
||||||
MessageType.Warning);
|
|
||||||
|
|
||||||
GUILayout.Space(10);
|
|
||||||
GUILayout.Label("REAL-TIME MULTI-USER SYNC", EditorStyles.boldLabel);
|
|
||||||
GUILayout.Space(10);
|
|
||||||
|
|
||||||
EditorGUI.BeginChangeCheck();
|
|
||||||
wsUrl = EditorGUILayout.TextField("WebSocket Server:", wsUrl);
|
|
||||||
if (EditorGUI.EndChangeCheck())
|
|
||||||
{
|
|
||||||
EditorPrefs.SetString("LiveSync_WS_URL", wsUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
GUILayout.Space(15);
|
|
||||||
|
|
||||||
if (!isConnected)
|
|
||||||
{
|
|
||||||
GUI.backgroundColor = new Color(0.2f, 0.6f, 0.2f);
|
|
||||||
if (GUILayout.Button("🔌 Connect Session", GUILayout.Height(40))) Connect();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GUI.backgroundColor = new Color(0.8f, 0.3f, 0.3f);
|
|
||||||
if (GUILayout.Button("🛑 Disconnect", GUILayout.Height(40))) Disconnect();
|
|
||||||
|
|
||||||
GUILayout.Space(15);
|
|
||||||
EditorGUILayout.HelpBox("🟢 Connected!\nTransforms are tracked in real-time.\nListening for Git updates...", MessageType.Info);
|
|
||||||
}
|
|
||||||
GUI.backgroundColor = Color.white;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void Connect()
|
|
||||||
{
|
|
||||||
if (ws != null && ws.State == WebSocketState.Open) return;
|
|
||||||
|
|
||||||
ws = new ClientWebSocket();
|
|
||||||
cts = new CancellationTokenSource();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await ws.ConnectAsync(new Uri(wsUrl), cts.Token);
|
|
||||||
isConnected = true;
|
|
||||||
UnityEngine.Debug.Log("Live Sync: Connected to Server!");
|
|
||||||
|
|
||||||
_ = ReceiveLoop();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
UnityEngine.Debug.LogError("Live Sync: Connection failed. Is the server running? " + e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void Disconnect()
|
|
||||||
{
|
|
||||||
if (ws != null)
|
|
||||||
{
|
|
||||||
cts?.Cancel();
|
|
||||||
if (ws.State == WebSocketState.Open) await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "Client disconnecting", CancellationToken.None);
|
|
||||||
ws.Dispose();
|
|
||||||
}
|
|
||||||
isConnected = false;
|
|
||||||
UnityEngine.Debug.Log("Live Sync: Disconnected.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EditorUpdate()
|
|
||||||
{
|
|
||||||
if (!isConnected || isNetworkApplying) return;
|
|
||||||
|
|
||||||
if (lastSelected != null && lastSelected.hasChanged)
|
|
||||||
{
|
|
||||||
SyncMessage msg = new SyncMessage
|
|
||||||
{
|
|
||||||
type = "TRANSFORM",
|
|
||||||
objectName = lastSelected.name,
|
|
||||||
position = lastSelected.position,
|
|
||||||
eulerAngles = lastSelected.eulerAngles,
|
|
||||||
localScale = lastSelected.localScale
|
|
||||||
};
|
|
||||||
|
|
||||||
SendMessage(JsonUtility.ToJson(msg));
|
|
||||||
lastSelected.hasChanged = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnSelectionChanged()
|
|
||||||
{
|
|
||||||
if (Selection.activeTransform != null)
|
|
||||||
{
|
|
||||||
lastSelected = Selection.activeTransform;
|
|
||||||
lastSelected.hasChanged = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void BroadcastGitUpdate()
|
|
||||||
{
|
|
||||||
if (!isConnected || ws == null || ws.State != WebSocketState.Open) return;
|
|
||||||
|
|
||||||
SyncMessage msg = new SyncMessage { type = "GIT_PULL" };
|
|
||||||
SendMessage(JsonUtility.ToJson(msg));
|
|
||||||
UnityEngine.Debug.Log("Live Sync: Broadcasted Git Update signal to team.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async void SendMessage(string json)
|
|
||||||
{
|
|
||||||
if (ws == null || ws.State != WebSocketState.Open) return;
|
|
||||||
byte[] bytes = Encoding.UTF8.GetBytes(json);
|
|
||||||
await ws.SendAsync(new ArraySegment<byte>(bytes), WebSocketMessageType.Text, true, cts.Token);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ReceiveLoop()
|
|
||||||
{
|
|
||||||
byte[] buffer = new byte[2048];
|
|
||||||
while (ws.State == WebSocketState.Open)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var result = await ws.ReceiveAsync(new ArraySegment<byte>(buffer), cts.Token);
|
|
||||||
if (result.MessageType == WebSocketMessageType.Text)
|
|
||||||
{
|
|
||||||
string json = Encoding.UTF8.GetString(buffer, 0, result.Count);
|
|
||||||
EditorApplication.delayCall += () => ProcessIncoming(json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch { break; }
|
|
||||||
}
|
|
||||||
isConnected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ProcessIncoming(string json)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
SyncMessage msg = JsonUtility.FromJson<SyncMessage>(json);
|
|
||||||
|
|
||||||
if (msg.type == "TRANSFORM")
|
|
||||||
{
|
|
||||||
GameObject target = GameObject.Find(msg.objectName);
|
|
||||||
if (target != null)
|
|
||||||
{
|
|
||||||
isNetworkApplying = true;
|
|
||||||
target.transform.position = msg.position;
|
|
||||||
target.transform.eulerAngles = msg.eulerAngles;
|
|
||||||
target.transform.localScale = msg.localScale;
|
|
||||||
target.transform.hasChanged = false;
|
|
||||||
isNetworkApplying = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (msg.type == "GIT_PULL")
|
|
||||||
{
|
|
||||||
UnityEngine.Debug.LogWarning("Live Sync: Teammate pushed new files! Starting auto-pull...");
|
|
||||||
GitPanel.RunGitCommand("pull --rebase origin HEAD");
|
|
||||||
AssetDatabase.Refresh();
|
|
||||||
UnityEngine.Debug.Log("Live Sync: Auto-pull complete. Files updated.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
UnityEngine.Debug.LogWarning("Live Sync: Failed to parse incoming message. " + e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "de.mrunknownde.gittool.Editor",
|
|
||||||
"rootNamespace": "",
|
|
||||||
"references": [],
|
|
||||||
"includePlatforms": [
|
|
||||||
"Editor"
|
|
||||||
],
|
|
||||||
"excludePlatforms": [],
|
|
||||||
"allowUnsafeCode": false,
|
|
||||||
"overrideReferences": false,
|
|
||||||
"precompiledReferences": [],
|
|
||||||
"autoReferenced": true,
|
|
||||||
"defineConstraints": [],
|
|
||||||
"versionDefines": [],
|
|
||||||
"noEngineReferences": false
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
/*
|
||||||
|
* ============================================================================
|
||||||
|
* ProTV Room Zone Manager
|
||||||
|
* ============================================================================
|
||||||
|
* Ein autarkes Trigger-Modul zur ressourcenschonenden Steuerung von
|
||||||
|
* ProTV / AVPro Instanzen in VRChat
|
||||||
|
*
|
||||||
|
* written by MrUnknownDE
|
||||||
|
* https://mrunknown.de
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
using UdonSharp;
|
||||||
|
using UnityEngine;
|
||||||
|
using VRC.SDKBase;
|
||||||
|
using VRC.Udon;
|
||||||
|
|
||||||
|
public class ProTVRoomZone : UdonSharpBehaviour
|
||||||
|
{
|
||||||
|
[Header("Der Videoplayer für diesen Raum")]
|
||||||
|
public GameObject localVideoPlayer;
|
||||||
|
[Space(10)]
|
||||||
|
[Header("Fade Settings")]
|
||||||
|
[Tooltip("Wie lange soll das Ein-/Ausblenden in Sekunden dauern?")]
|
||||||
|
public float fadeDuration = 1.5f;
|
||||||
|
|
||||||
|
[Tooltip("Ziehe hier die AudioSources des ProTVs rein - damit die Lautstärke smooth gefadet wird.")]
|
||||||
|
public AudioSource[] audioSources;
|
||||||
|
|
||||||
|
private BoxCollider roomCollider;
|
||||||
|
private float fadeProgress = 0f;
|
||||||
|
private int fadeState = 0;
|
||||||
|
|
||||||
|
// Hier speichern wir die echte Lautstärke, bevor sie verfälscht wird
|
||||||
|
private float[] savedVolumes;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
roomCollider = GetComponent<BoxCollider>();
|
||||||
|
|
||||||
|
// Arrays initialisieren und Basis-Lautstärke beim Start sichern
|
||||||
|
if (audioSources != null && audioSources.Length > 0)
|
||||||
|
{
|
||||||
|
savedVolumes = new float[audioSources.Length];
|
||||||
|
for (int i = 0; i < audioSources.Length; i++)
|
||||||
|
{
|
||||||
|
if (audioSources[i] != null) savedVolumes[i] = audioSources[i].volume;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SendCustomEventDelayedSeconds(nameof(CheckSpawnPosition), 2.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CheckSpawnPosition()
|
||||||
|
{
|
||||||
|
VRCPlayerApi player = Networking.LocalPlayer;
|
||||||
|
if (!Utilities.IsValid(player)) return;
|
||||||
|
|
||||||
|
if (roomCollider != null && roomCollider.bounds.Contains(player.GetPosition()))
|
||||||
|
{
|
||||||
|
if (localVideoPlayer != null) localVideoPlayer.SetActive(true);
|
||||||
|
fadeProgress = 1f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UpdateSavedVolumes();
|
||||||
|
|
||||||
|
if (localVideoPlayer != null) localVideoPlayer.SetActive(false);
|
||||||
|
fadeProgress = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnPlayerTriggerEnter(VRCPlayerApi player)
|
||||||
|
{
|
||||||
|
if (!Utilities.IsValid(player) || !player.isLocal) return;
|
||||||
|
if (localVideoPlayer != null) localVideoPlayer.SetActive(true);
|
||||||
|
fadeProgress = 0f;
|
||||||
|
fadeState = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnPlayerTriggerExit(VRCPlayerApi player)
|
||||||
|
{
|
||||||
|
if (!Utilities.IsValid(player) || !player.isLocal) return;
|
||||||
|
UpdateSavedVolumes();
|
||||||
|
fadeProgress = 1f;
|
||||||
|
fadeState = -1; // Starte Fade Out
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (fadeState == 0) return;
|
||||||
|
if (fadeState == 1) // FADE IN
|
||||||
|
{
|
||||||
|
fadeProgress += Time.deltaTime / fadeDuration;
|
||||||
|
if (fadeProgress >= 1f)
|
||||||
|
{
|
||||||
|
fadeProgress = 1f;
|
||||||
|
fadeState = 0;
|
||||||
|
}
|
||||||
|
ApplyFadedVolume();
|
||||||
|
}
|
||||||
|
else if (fadeState == -1) // FADE OUT
|
||||||
|
{
|
||||||
|
fadeProgress -= Time.deltaTime / fadeDuration;
|
||||||
|
if (fadeProgress <= 0f)
|
||||||
|
{
|
||||||
|
fadeProgress = 0f;
|
||||||
|
fadeState = 0;
|
||||||
|
|
||||||
|
// DER PRO-TV FIX:
|
||||||
|
RestoreOriginalVolume();
|
||||||
|
|
||||||
|
if (localVideoPlayer != null) localVideoPlayer.SetActive(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ApplyFadedVolume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateSavedVolumes()
|
||||||
|
{
|
||||||
|
if (audioSources == null) return;
|
||||||
|
for (int i = 0; i < audioSources.Length; i++)
|
||||||
|
{
|
||||||
|
if (audioSources[i] != null && audioSources[i].volume > 0.05f)
|
||||||
|
{
|
||||||
|
savedVolumes[i] = audioSources[i].volume;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ApplyFadedVolume()
|
||||||
|
{
|
||||||
|
if (audioSources == null || savedVolumes == null) return;
|
||||||
|
for (int i = 0; i < audioSources.Length; i++)
|
||||||
|
{
|
||||||
|
if (audioSources[i] != null)
|
||||||
|
{
|
||||||
|
audioSources[i].volume = savedVolumes[i] * fadeProgress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RestoreOriginalVolume()
|
||||||
|
{
|
||||||
|
if (audioSources == null || savedVolumes == null) return;
|
||||||
|
for (int i = 0; i < audioSources.Length; i++)
|
||||||
|
{
|
||||||
|
if (audioSources[i] != null)
|
||||||
|
{
|
||||||
|
audioSources[i].volume = savedVolumes[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user