15 Commits

Author SHA1 Message Date
MrUnknownDE a3eb6cf71f fix: git credentials manager issue 2026-05-05 20:00:09 +02:00
MrUnknownDE a3a23902ab fix: crash issues on push 2026-05-05 19:43:54 +02:00
MrUnknownDE e89eb856ca remove old sync project from dependen 2026-05-05 19:37:35 +02:00
MrUnknownDE 689ceca124 add AudioLink BPM Detector 2026-04-11 10:44:03 +02:00
MrUnknownDE 185f1cc96a remove sync project ^^ 2026-04-10 22:08:08 +02:00
MrUnknownDE 32a428502d add audio source fade 2026-04-10 22:05:33 +02:00
MrUnknownDE 50017d40c8 Merge branch 'main' of github.com:MrUnknownDE/unity-gittool 2026-04-10 21:36:28 +02:00
MrUnknownDE 5490b72e5d add ProTV Room Zone Script :D 2026-04-10 21:35:01 +02:00
MrUnknownDE 9250fc71ed Fix formatting in usage section of README
Updated usage instructions for GIT Version Control.
2026-04-07 16:27:53 +02:00
MrUnknownDE 8318bd6a6e add generation packages inventar list 2026-04-07 16:26:30 +02:00
MrUnknownDE 0c613129f5 start livesync panel ^^ 2026-04-07 13:27:01 +02:00
MrUnknownDE 7bc0eee024 add git console 2026-04-07 13:05:14 +02:00
MrUnknownDE 48134f2a03 add pull button 2026-04-07 13:02:27 +02:00
MrUnknownDE 00ab946aa0 add unity settings check 2026-04-07 11:28:54 +02:00
MrUnknownDE 992e67eee2 Update Readme.md 2026-04-07 11:19:18 +02:00
6 changed files with 639 additions and 76 deletions
+64
View File
@@ -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;
}
}
}
+43
View File
@@ -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);
}
}
}
}
+364 -40
View File
@@ -13,6 +13,9 @@ public class GitPanel : EditorWindow
private bool isGitInstalled = true;
private bool hasRepo = false;
private bool settingsCorrect = true;
private string settingsWarning = "";
private string currentBranchName = "unknown";
private string[] availableBranches = new string[0];
private int selectedBranchIndex = 0;
@@ -21,14 +24,22 @@ public class GitPanel : EditorWindow
private Vector2 scrollPositionChanges;
private Vector2 scrollPositionHistory;
// STATISCH: Damit RunGitCommand darauf zugreifen kann und das Log beim Neuladen erhalten bleibt!
private static string gitLogOutput = "";
private Vector2 scrollPositionLog;
private int selectedTab = 0;
private string[] tabNames = { "Changes", "History" };
// NEU: Settings & Override
private bool showSettings = false;
private string webUrlOverride = "";
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 List<CommitInfo> commitHistory = new List<CommitInfo>();
@@ -36,25 +47,60 @@ public class GitPanel : EditorWindow
public static void ShowWindow()
{
GitPanel window = GetWindow<GitPanel>("GIT Version Control System");
window.minSize = new Vector2(350, 550);
window.minSize = new Vector2(380, 650);
}
private void OnEnable()
{
// Generiert einen einzigartigen Key für dieses spezifische Unity-Projekt
EditorApplication.update += OnEditorUpdate;
prefsKey = $"GitTool_WebUrl_{Application.dataPath.GetHashCode()}";
webUrlOverride = EditorPrefs.GetString(prefsKey, "");
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()
{
CheckGitInstallation();
if (!isGitInstalled) return;
lastRefreshTime = EditorApplication.timeSinceStartup;
CheckGitInstallation();
CheckUnitySettings();
if (!isGitInstalled) return;
CheckRepoStatus();
if (hasRepo)
@@ -79,32 +125,92 @@ public class GitPanel : EditorWindow
} catch { isGitInstalled = false; }
}
// FIX: Nutzt jetzt die aktuelle Unity-API (VersionControlSettings.mode)
private void CheckUnitySettings()
{
settingsCorrect = true;
settingsWarning = "";
if (VersionControlSettings.mode != "Visible Meta Files")
{
settingsCorrect = false;
settingsWarning += "• Version Control Mode must be 'Visible Meta Files'\n";
}
if (EditorSettings.serializationMode != SerializationMode.ForceText)
{
settingsCorrect = false;
settingsWarning += "• Asset Serialization must be 'Force Text'\n";
}
}
private void FixUnitySettings()
{
VersionControlSettings.mode = "Visible Meta Files";
EditorSettings.serializationMode = SerializationMode.ForceText;
UnityEngine.Debug.Log("Git-Tool: Unity Project Settings updated for Git compatibility.");
RefreshData();
}
private void SetDefaultCommitMessage() { commitMessage = $"Auto-Save: {System.DateTime.Now:yyyy-MM-dd HH:mm:ss}"; }
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.Label("GIT Version Control System", EditorStyles.boldLabel);
if (hasRepo) GUILayout.Label($"Active Branch: {currentBranchName}", EditorStyles.miniLabel);
GUILayout.Space(5);
if (!settingsCorrect)
{
EditorGUILayout.BeginVertical("box");
EditorGUILayout.HelpBox("INCOMPATIBLE PROJECT SETTINGS:\n" + settingsWarning, MessageType.Error);
GUI.backgroundColor = new Color(1f, 0.5f, 0f);
if (GUILayout.Button("Fix Project Settings Now"))
{
FixUnitySettings();
}
GUI.backgroundColor = Color.white;
EditorGUILayout.EndVertical();
GUILayout.Space(10);
}
if (!isGitInstalled) { RenderGitMissingUI(); return; }
if (!hasRepo) { RenderInitUI(); return; }
// --- NEU: SETTINGS FOLDOUT ---
showSettings = EditorGUILayout.Foldout(showSettings, "⚙️ Repository Settings");
showSettings = EditorGUILayout.Foldout(showSettings, "Repository Settings");
if (showSettings)
{
EditorGUILayout.BeginVertical("box");
GUILayout.Label("Web Override (For custom SSH instances)", EditorStyles.miniBoldLabel);
EditorGUI.BeginChangeCheck();
webUrlOverride = EditorGUILayout.TextField("Web URL:", webUrlOverride);
if (EditorGUI.EndChangeCheck())
{
EditorPrefs.SetString(prefsKey, webUrlOverride.Trim());
}
EditorGUILayout.HelpBox("e.g. https://git.mrunk.de/mrunknownde/my-repo\nLeaves SSH untouched but fixes browser links.", MessageType.None);
GUILayout.Space(10);
GUILayout.Label("Inventory Management", EditorStyles.miniBoldLabel);
if (GUILayout.Button("Sync Package Inventory (Unity & VRChat)", GUILayout.Height(25)))
{
ExportPackageInventory();
}
EditorGUILayout.EndVertical();
GUILayout.Space(5);
}
@@ -118,7 +224,7 @@ public class GitPanel : EditorWindow
private void RenderGitMissingUI()
{
EditorGUILayout.HelpBox("CRITICAL: Git not found. Please install Git and restart Unity.", MessageType.Error);
EditorGUILayout.HelpBox("CRITICAL: Git not found.", MessageType.Error);
if (GUILayout.Button("Download Git for Windows", GUILayout.Height(30))) Application.OpenURL("https://git-scm.com/download/win");
}
@@ -128,24 +234,23 @@ public class GitPanel : EditorWindow
remoteUrlInput = EditorGUILayout.TextField("Remote URL:", remoteUrlInput);
if (GUILayout.Button("Initialize Repository", GUILayout.Height(30)))
{
RunGitCommand("init");
RunGitCommand("branch -M main");
RunGitCommand("init", true);
RunGitCommand("branch -M main", true);
if (!string.IsNullOrWhiteSpace(remoteUrlInput)) {
RunGitCommand($"remote add origin \"{remoteUrlInput.Trim()}\"");
RunGitCommand("pull origin main --allow-unrelated-histories --no-edit");
RunGitCommand($"remote add origin \"{remoteUrlInput.Trim()}\"", true);
RunGitCommand("pull origin main --allow-unrelated-histories --no-edit", true);
}
GenerateUnityGitIgnore();
AssetDatabase.Refresh();
RunGitCommand("add .gitignore");
RunGitCommand("commit -m \"Initial commit (GitIgnore)\"");
if (!string.IsNullOrWhiteSpace(remoteUrlInput)) RunGitCommand("push -u origin main");
RunGitCommand("add .gitignore", true);
RunGitCommand("commit -m \"Initial commit (GitIgnore)\"", true);
if (!string.IsNullOrWhiteSpace(remoteUrlInput)) RunGitCommand("push -u origin main", true);
RefreshData();
}
}
private void RenderGitUI()
{
// --- BRANCH MANAGEMENT ---
EditorGUILayout.BeginVertical("box");
GUILayout.Label("Branch Management", EditorStyles.boldLabel);
@@ -155,7 +260,8 @@ public class GitPanel : EditorWindow
int newIndex = EditorGUILayout.Popup("Switch Branch:", selectedBranchIndex, availableBranches);
if (EditorGUI.EndChangeCheck() && newIndex != selectedBranchIndex)
{
RunGitCommand($"checkout \"{availableBranches[newIndex]}\"");
RunGitCommand($"checkout \"{availableBranches[newIndex]}\"", true);
AssetDatabase.Refresh();
RefreshData();
return;
}
@@ -168,7 +274,7 @@ public class GitPanel : EditorWindow
{
if (!string.IsNullOrWhiteSpace(newBranchName))
{
RunGitCommand($"checkout -b \"{newBranchName.Trim()}\"");
RunGitCommand($"checkout -b \"{newBranchName.Trim()}\"", true);
newBranchName = "";
RefreshData();
GUI.FocusControl(null);
@@ -180,26 +286,68 @@ public class GitPanel : EditorWindow
EditorGUILayout.EndVertical();
GUILayout.Space(10);
// --- COMMIT BEREICH ---
commitMessage = EditorGUILayout.TextField(commitMessage, GUILayout.Height(25));
EditorGUILayout.BeginHorizontal();
GUI.backgroundColor = new Color(0.2f, 0.4f, 0.8f);
if (GUILayout.Button("✓ Commit & Push", GUILayout.Height(30)))
if (GUILayout.Button("✓ Push", GUILayout.Height(30)))
{
// Unity APIs must stay on the main thread
UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes();
AssetDatabase.SaveAssets();
if (string.IsNullOrWhiteSpace(commitMessage)) SetDefaultCommitMessage();
RunGitCommand("add .");
RunGitCommand($"commit -m \"{commitMessage}\"");
RunGitCommand("push -u origin HEAD");
commitMessage = "";
RefreshData();
string msgSnapshot = commitMessage;
RunNetworkCommand("Committing and pushing... (a browser window may open for authentication)",
() =>
{
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
{
UnityEngine.Debug.Log("Git-Tool: Changes successfully pushed!");
commitMessage = "";
}
RefreshData();
});
}
GUI.backgroundColor = new Color(0.8f, 0.6f, 0.2f);
if (GUILayout.Button("⬇️ Pull", GUILayout.Width(80), GUILayout.Height(30)))
{
UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes();
AssetDatabase.SaveAssets();
RunNetworkCommand("Pulling from remote... (a browser window may open for authentication)",
() => RunGitCommand("pull", true, 180000),
result =>
{
AssetDatabase.Refresh();
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();
});
}
GUI.backgroundColor = new Color(0.8f, 0.3f, 0.3f);
if (GUILayout.Button("⎌ Revert All", GUILayout.Width(80), GUILayout.Height(30)))
if (GUILayout.Button("⎌ Revert", GUILayout.Width(80), GUILayout.Height(30)))
{
if (EditorUtility.DisplayDialog("Revert Changes?", "Discard ALL uncommitted changes?", "Yes", "Cancel")) {
RunGitCommand("reset --hard HEAD"); RunGitCommand("clean -fd"); RefreshData();
RunGitCommand("reset --hard HEAD", true);
RunGitCommand("clean -fd", true);
AssetDatabase.Refresh();
RefreshData();
}
}
GUI.backgroundColor = Color.white;
@@ -215,6 +363,17 @@ public class GitPanel : EditorWindow
if (changedFiles.Length == 0) GUILayout.Label("No changes.");
else RenderFileList(changedFiles);
EditorGUILayout.EndScrollView();
GUILayout.Space(5);
EditorGUILayout.BeginHorizontal();
GUILayout.Label("GIT CONSOLE", EditorStyles.boldLabel);
if (GUILayout.Button("Clear", GUILayout.Width(50))) gitLogOutput = "";
EditorGUILayout.EndHorizontal();
scrollPositionLog = EditorGUILayout.BeginScrollView(scrollPositionLog, "box", GUILayout.Height(120));
GUIStyle logStyle = new GUIStyle(EditorStyles.label) { wordWrap = true, fontSize = 10 };
GUILayout.Label(string.IsNullOrEmpty(gitLogOutput) ? "Ready." : gitLogOutput, logStyle);
EditorGUILayout.EndScrollView();
}
private void RenderHistoryUI()
@@ -256,7 +415,6 @@ public class GitPanel : EditorWindow
private void OpenCommitInBrowser(string hash)
{
// NEU: Override Logik greift zuerst!
if (!string.IsNullOrWhiteSpace(webUrlOverride))
{
string url = webUrlOverride;
@@ -266,7 +424,6 @@ public class GitPanel : EditorWindow
return;
}
// Standard Fallback Logik (wenn kein Override gesetzt ist)
string remoteUrl = RunGitCommand("config --get remote.origin.url").Trim();
if (string.IsNullOrEmpty(remoteUrl)) return;
@@ -277,7 +434,6 @@ public class GitPanel : EditorWindow
if (firstColon != -1) remoteUrl = remoteUrl.Remove(firstColon, 1).Insert(firstColon, "/");
}
if (remoteUrl.EndsWith(".git")) remoteUrl = remoteUrl.Substring(0, remoteUrl.Length - 4);
Application.OpenURL($"{remoteUrl}/commit/{hash}");
}
@@ -325,11 +481,179 @@ public class GitPanel : EditorWindow
if (!File.Exists(path)) File.WriteAllText(path, ".idea\n.vs\nbin\nobj\n/Library\n/Temp\n/UserSettings\n/Configs\n/*.csproj\n/*.sln\n/Logs\n/Packages/*\n!/Packages/manifest.json\n!/Packages/packages-lock.json\n~UnityDirMonSyncFile~*");
}
public static string RunGitCommand(string args) {
try {
ProcessStartInfo si = new ProcessStartInfo("git", args) { WorkingDirectory = Path.GetFullPath(Path.Combine(Application.dataPath, "..")), UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true };
using (Process p = Process.Start(si)) { string o = p.StandardOutput.ReadToEnd(); p.WaitForExit(); return o; }
} catch { return ""; }
private void ExportPackageInventory()
{
string rootPath = Path.GetFullPath(Path.Combine(Application.dataPath, ".."));
string outputPath = Path.Combine(rootPath, "PACKAGES.md");
string unityManifest = Path.Combine(rootPath, "Packages", "manifest.json");
string vpmManifest = Path.Combine(rootPath, "Packages", "vpm-manifest.json");
List<string> mdLines = new List<string>();
mdLines.Add("# 📦 Project Dependencies Inventory");
mdLines.Add($"\n*Last Update: {System.DateTime.Now:yyyy-MM-dd HH:mm:ss}*");
mdLines.Add("\n> [!TIP]\n> This list helps to restore the workspace if the Creator Companion or Unity fails to auto-resolve dependencies.\n");
int totalFound = 0;
totalFound += ParseManifest(unityManifest, "Unity Standard & Scoped Dependencies", mdLines);
totalFound += ParseManifest(vpmManifest, "VRChat Package Manager (VPM) Dependencies", mdLines);
try {
File.WriteAllLines(outputPath, mdLines, System.Text.Encoding.UTF8);
RunGitCommand($"add \"{outputPath}\"");
UnityEngine.Debug.Log($"Git-Tool: PACKAGES.md updated. {totalFound} entries found.");
} catch (System.Exception e) {
UnityEngine.Debug.LogError("Git-Tool: Failed to write PACKAGES.md: " + e.Message);
}
}
private int ParseManifest(string path, string sectionTitle, List<string> outputList)
{
if (!File.Exists(path)) return 0;
int count = 0;
try {
string content = File.ReadAllText(path);
// 1. Find the start of the "dependencies" block
int startIndex = content.IndexOf("\"dependencies\"");
if (startIndex == -1) return 0;
// Find the first opening brace after the key
startIndex = content.IndexOf("{", startIndex);
if (startIndex == -1) return 0;
// 2. Extract exactly this block by counting braces
int openBraces = 0;
int endIndex = startIndex;
for (int i = startIndex; i < content.Length; i++) {
if (content[i] == '{') openBraces++;
if (content[i] == '}') {
openBraces--;
if (openBraces == 0) {
endIndex = i;
break;
}
}
}
if (endIndex <= startIndex) return 0;
outputList.Add($"## {sectionTitle}");
outputList.Add("| Package Name | Version / Source |");
outputList.Add("| :--- | :--- |");
// 3. Parse the isolated block line by line
string dependenciesBlock = content.Substring(startIndex, endIndex - startIndex + 1);
string[] blockLines = dependenciesBlock.Split(new[] { '\r', '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
string currentVpmPackage = "";
foreach (string line in blockLines) {
string trimmed = line.Trim();
if (trimmed == "{" || trimmed == "}" || trimmed == "},") continue;
if (trimmed.StartsWith("\"")) {
string[] parts = trimmed.Split(new char[] { ':' }, 2);
if (parts.Length == 2) {
string key = parts[0].Replace("\"", "").Trim();
string rawValue = parts[1].Trim();
if (rawValue.StartsWith("{")) {
// VPM package start, e.g. "com.vrchat.base": {
currentVpmPackage = key;
}
else if (key == "version") {
// VPM package version, e.g. "version": "3.10.2"
string val = rawValue.Replace("\"", "").Replace(",", "").Trim();
if (!string.IsNullOrEmpty(currentVpmPackage)) {
outputList.Add($"| `{currentVpmPackage}` | {val} |");
count++;
currentVpmPackage = "";
}
}
else if (!rawValue.StartsWith("{")) {
// Flat Unity package, e.g. "com.unity.timeline": "1.2.3"
string val = rawValue.Replace("\"", "").Replace(",", "").Trim();
outputList.Add($"| `{key}` | {val} |");
count++;
}
}
}
}
} catch (System.Exception e) {
UnityEngine.Debug.LogWarning($"Git-Tool: Could not read {Path.GetFileName(path)}: {e.Message}");
}
if (count == 0) {
outputList.Add("| - | No entries found |");
}
outputList.Add("");
return count;
}
public static string RunGitCommand(string args, bool logAction = false, int timeoutMs = 10000)
{
try
{
ProcessStartInfo si = new ProcessStartInfo("git", args)
{
WorkingDirectory = Path.GetFullPath(Path.Combine(Application.dataPath, "..")),
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = 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";
var stdout = new System.Text.StringBuilder();
var stderr = new System.Text.StringBuilder();
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();
string result = stdout.ToString() + (stderr.Length > 0 ? "\n" + stderr : "");
if (logAction)
{
string entry = $"[{System.DateTime.Now:HH:mm:ss}] > git {args}\n";
if (!string.IsNullOrWhiteSpace(result)) entry += result.Trim() + "\n\n";
gitLogOutput = entry + gitLogOutput;
if (gitLogOutput.Length > 10000) gitLogOutput = gitLogOutput.Substring(0, 10000);
}
return result;
}
}
catch (System.Exception ex)
{
UnityEngine.Debug.LogWarning($"Git-Tool: Exception running git {args}: {ex.Message}");
return "";
}
}
}
@@ -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
}
+157
View File
@@ -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];
}
}
}
}
+4 -13
View File
@@ -44,19 +44,10 @@ Listen up, because the German Copyright Law (*Urheberrechtsgesetz*) doesn't take
This tool is installed manually directly into your Unity project.
### Method 1: Unity Package Manager (Recommended)
1. Go to the [Releases page](../../releases/latest) of this repository.
2. Download the latest `de.mrunknownde.gittool-vX.X.X.zip` file.
3. Extract the ZIP file into a folder on your PC.
4. Open your Unity Project.
5. Go to `Window` -> `Package Manager`.
6. Click the **+** icon in the top left corner and select **Add package from disk...**.
7. Navigate to the extracted folder, select the `package.json` file, and click Open.
### Method 2: Direct Folder Drop
1. Download the latest `.zip` release.
### Direct Folder Drop
1. Download the latest `mrunknownde-vcc-tools-v20xx-xx-xx.zip` release.
2. Extract the archive.
3. Drag and drop the extracted folder directly into the `Packages` directory inside your Unity project's root folder (using Windows Explorer / File Explorer, not inside the Unity Editor window). Unity will automatically compile the tools.
3. Drag and drop the extracted folder directly into the `Assets` directory inside your Unity project's root folder (using Windows Explorer / File Explorer, not inside the Unity Editor window). Unity will automatically compile the tools.
---
@@ -64,7 +55,7 @@ This tool is installed manually directly into your Unity project.
Once installed, you can access the tools via the top menu bar in Unity:
`Tools` -> `MrUnknownDE` -> `GIT Version Control`
`Tools` -> `MrUnknownDE` -> `GIT Version Control`<br>
`Tools` -> `MrUnknownDE` -> `Discord RPC`
The tools will open as floating windows. You can easily dock them into your custom Unity layout (e.g., right next to the Inspector or Console).