6 Commits

Author SHA1 Message Date
a68f45734b ähm merg from old branch 2026-04-06 20:02:28 +02:00
df4ade6977 add staging system 2026-04-06 18:39:24 +02:00
889b677830 remove broken version 2026-04-06 18:38:14 +02:00
8c0935ac92 update index.json 2026-04-06 18:32:04 +02:00
467f665303 rename repo "again" ^^ 2026-04-06 18:19:12 +02:00
a0db61aa07 add workflow for vcc release 2026-04-06 18:10:37 +02:00
6 changed files with 262 additions and 58 deletions

1
CNAME
View File

@@ -1 +0,0 @@
vcc.mrunk.de

194
Editor/DiscordRPCPanel.cs Normal file
View File

@@ -0,0 +1,194 @@
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using System;
using System.IO.Pipes;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
public class DiscordRPCPanel : EditorWindow
{
// === HIER DEINE DISCORD APPLICATION ID EINTRAGEN ===
private const string clientId = "1490767097096048780";
private static bool isEnabled = false;
private static bool hideSceneName = false;
private static string customStatus = "Building a VRChat World/Avatar";
private static NamedPipeClientStream pipe;
private static long startTime;
[MenuItem("Tools/MrUnknownDE/Discord RPC")]
public static void ShowWindow()
{
DiscordRPCPanel window = GetWindow<DiscordRPCPanel>("Discord RPC");
window.minSize = new Vector2(300, 250);
}
private void OnEnable()
{
// Lädt gespeicherte Einstellungen
isEnabled = EditorPrefs.GetBool("DiscordRPC_Enabled", false);
hideSceneName = EditorPrefs.GetBool("DiscordRPC_HideScene", false);
customStatus = EditorPrefs.GetString("DiscordRPC_Status", "Building a VRChat World");
if (isEnabled) ConnectToDiscord();
// Hooks in Unity einhängen
EditorApplication.playModeStateChanged -= OnPlayModeChanged;
EditorApplication.playModeStateChanged += OnPlayModeChanged;
EditorSceneManager.sceneOpened -= OnSceneOpened;
EditorSceneManager.sceneOpened += OnSceneOpened;
}
private void OnDisable()
{
if (pipe != null && pipe.IsConnected) pipe.Close();
}
private void OnGUI()
{
GUILayout.Space(10);
GUILayout.Label("DISCORD RICH PRESENCE", EditorStyles.boldLabel);
GUILayout.Space(5);
EditorGUI.BeginChangeCheck();
// Status Toggle
GUI.backgroundColor = isEnabled ? new Color(0.2f, 0.8f, 0.2f) : new Color(0.8f, 0.2f, 0.2f);
if (GUILayout.Button(isEnabled ? "Status: ONLINE" : "Status: OFFLINE", GUILayout.Height(30)))
{
isEnabled = !isEnabled;
EditorPrefs.SetBool("DiscordRPC_Enabled", isEnabled);
if (isEnabled) ConnectToDiscord();
else DisconnectDiscord();
}
GUI.backgroundColor = Color.white;
GUILayout.Space(15);
GUILayout.Label("SETTINGS", EditorStyles.boldLabel);
// Custom Status Input
GUILayout.Label("Custom Status (Line 1):");
customStatus = EditorGUILayout.TextField(customStatus);
// Privacy Toggle
hideSceneName = EditorGUILayout.Toggle("Hide Scene Name (Privacy)", hideSceneName);
if (EditorGUI.EndChangeCheck())
{
EditorPrefs.SetBool("DiscordRPC_HideScene", hideSceneName);
EditorPrefs.SetString("DiscordRPC_Status", customStatus);
if (isEnabled) UpdatePresence();
}
GUILayout.Space(15);
EditorGUILayout.HelpBox("Wenn aktiv, sieht dein Discord-Server in deinem Profil, an welcher Szene du gerade baust.", MessageType.Info);
}
// --- UNITY EVENT HOOKS ---
private void OnPlayModeChanged(PlayModeStateChange state)
{
if (isEnabled) UpdatePresence();
}
private void OnSceneOpened(UnityEngine.SceneManagement.Scene scene, OpenSceneMode mode)
{
if (isEnabled) UpdatePresence();
}
// --- DISCORD IPC LOGIK ---
private async void ConnectToDiscord()
{
if (pipe != null && pipe.IsConnected) return;
try
{
pipe = new NamedPipeClientStream(".", "discord-ipc-0", PipeDirection.InOut, PipeOptions.Asynchronous);
await pipe.ConnectAsync(2000);
// Handshake (Opcode 0)
string handshake = "{\"v\": 1, \"client_id\": \"" + clientId + "\"}";
SendFrame(0, handshake);
startTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
UpdatePresence();
UnityEngine.Debug.Log("Discord RPC Connected!");
}
catch (Exception)
{
UnityEngine.Debug.LogWarning("Discord RPC: Konnte keine Verbindung zu Discord herstellen. Läuft Discord?");
isEnabled = false;
}
}
private void DisconnectDiscord()
{
if (pipe != null && pipe.IsConnected)
{
pipe.Close();
pipe.Dispose();
}
pipe = null;
UnityEngine.Debug.Log("Discord RPC Disconnected.");
}
private void UpdatePresence()
{
if (pipe == null || !pipe.IsConnected) return;
string sceneName = hideSceneName ? "Secret Map" : EditorSceneManager.GetActiveScene().name;
if (string.IsNullOrEmpty(sceneName)) sceneName = "Unsaved Scene";
string stateText = EditorApplication.isPlaying ? "Testet im Playmode" : $"Editiert: {sceneName}.unity";
// Flieht die Strings für sicheres JSON
string safeStatus = customStatus.Replace("\"", "\\\"");
string safeState = stateText.Replace("\"", "\\\"");
// Das Activity Payload (Opcode 1)
string json = $@"{{
""cmd"": ""SET_ACTIVITY"",
""args"": {{
""pid"": {Process.GetCurrentProcess().Id},
""activity"": {{
""details"": ""{safeStatus}"",
""state"": ""{safeState}"",
""timestamps"": {{
""start"": {startTime}
}},
""instance"": false
}}
}},
""nonce"": ""1""
}}";
SendFrame(1, json);
}
private void SendFrame(int opcode, string payload)
{
if (pipe == null || !pipe.IsConnected) return;
byte[] payloadBytes = Encoding.UTF8.GetBytes(payload);
int length = payloadBytes.Length;
byte[] buffer = new byte[8 + length];
BitConverter.GetBytes(opcode).CopyTo(buffer, 0);
BitConverter.GetBytes(length).CopyTo(buffer, 4);
payloadBytes.CopyTo(buffer, 8);
try
{
pipe.Write(buffer, 0, buffer.Length);
}
catch (Exception e)
{
UnityEngine.Debug.LogError("Discord RPC Error: " + e.Message);
DisconnectDiscord();
}
}
}

View File

@@ -7,6 +7,7 @@ using System.Collections.Generic;
public class GitPanel : EditorWindow
{
private string commitMessage = "";
private string remoteUrlInput = ""; // NEU: Speicher für die Remote-URL
private bool hasRepo = false;
private string[] changedFiles = new string[0];
private Vector2 scrollPositionChanges;
@@ -18,7 +19,7 @@ public class GitPanel : EditorWindow
private struct CommitInfo { public string hash; public string date; public string message; }
private List<CommitInfo> commitHistory = new List<CommitInfo>();
[MenuItem("Tools/Git-Tool")]
[MenuItem("Tools/MrUnknownDE/Git-Tool")]
public static void ShowWindow()
{
GitPanel window = GetWindow<GitPanel>("Source Control");
@@ -26,9 +27,25 @@ public class GitPanel : EditorWindow
}
private void OnEnable()
{
RefreshData();
}
private void OnFocus()
{
RefreshData();
}
public void RefreshData()
{
CheckRepoStatus();
SetDefaultCommitMessage();
if (string.IsNullOrWhiteSpace(commitMessage) || commitMessage.StartsWith("Auto-Save:"))
{
SetDefaultCommitMessage();
}
Repaint();
}
private void SetDefaultCommitMessage()
@@ -58,13 +75,42 @@ public class GitPanel : EditorWindow
private void RenderInitUI()
{
EditorGUILayout.HelpBox("No local Git repository found. Initialize current project folder?", MessageType.Warning);
GUILayout.Space(10);
GUILayout.Label("Remote Repository URL (Optional):", EditorStyles.boldLabel);
remoteUrlInput = EditorGUILayout.TextField(remoteUrlInput, GUILayout.Height(25));
EditorGUILayout.HelpBox("e.g., https://github.com/user/repo.git or git@gitea.domain.com:user/repo.git", MessageType.Info);
GUILayout.Space(10);
if (GUILayout.Button("Initialize Repository", GUILayout.Height(30)))
{
RunGitCommand("init");
// Branch direkt sauber auf "main" setzen (verhindert Konflikte mit alten "master" Defaults)
RunGitCommand("branch -M main");
// Remote URL hinzufügen, falls angegeben
if (!string.IsNullOrWhiteSpace(remoteUrlInput))
{
RunGitCommand($"remote add origin \"{remoteUrlInput.Trim()}\"");
}
GenerateUnityGitIgnore();
RunGitCommand("add .gitignore");
RunGitCommand("commit -m \"Initial commit (GitIgnore)\"");
CheckRepoStatus();
// Initialen Push ausführen, wenn ein Remote existiert
if (!string.IsNullOrWhiteSpace(remoteUrlInput))
{
RunGitCommand("push -u origin main");
UnityEngine.Debug.Log("Git-Tool: Repository initialized and pushed to remote!");
}
else
{
UnityEngine.Debug.Log("Git-Tool: Local repository initialized successfully.");
}
RefreshData();
}
}
@@ -81,8 +127,8 @@ public class GitPanel : EditorWindow
RunGitCommand($"commit -m \"{commitMessage}\"");
RunGitCommand("push");
SetDefaultCommitMessage();
CheckRepoStatus();
commitMessage = "";
RefreshData();
UnityEngine.Debug.Log("Git-Tool: Changes successfully pushed!");
}
GUI.backgroundColor = Color.white;
@@ -95,8 +141,7 @@ public class GitPanel : EditorWindow
GUILayout.Label($"CHANGES ({changedFiles.Length})", EditorStyles.boldLabel);
if (GUILayout.Button("↻", GUILayout.Width(25)))
{
CheckRepoStatus();
SetDefaultCommitMessage();
RefreshData();
}
EditorGUILayout.EndHorizontal();
@@ -275,4 +320,20 @@ obj
}
catch { return ""; }
}
}
public class GitSaveListener : UnityEditor.AssetModificationProcessor
{
public static string[] OnWillSaveAssets(string[] paths)
{
EditorApplication.delayCall += () =>
{
if (EditorWindow.HasOpenInstances<GitPanel>())
{
EditorWindow.GetWindow<GitPanel>().RefreshData();
}
};
return paths;
}
}

View File

@@ -10,16 +10,6 @@ A lightweight, integrated Source Control Panel built directly into Unity. Design
- `Double Click` on a file -> Opens the built-in Code Diff Viewer right inside the Editor.
- **History View:** Browse your latest commits. Click any commit to open it directly in your remote web view (Gitea, GitHub, GitLab).
## 🚀 Installation via VRChat Creator Companion (VCC)
You can add this tool as a custom package directly into your VCC.
1. Open the VRChat Creator Companion.
2. Navigate to **Settings** -> **Packages**.
3. Click on **Add Repository**.
4. Enter your custom repo URL: `https://vcc.mrunk.de/index.json`
5. In your project views, under "Manage Project", the **VRChat Git Control Tool** will now appear. Simply click the plus icon to add it.
## 🛠️ Manual Installation
1. Download the latest version as a `.zip` archive.
2. Extract the folder.

View File

@@ -1,28 +0,0 @@
{
"name": "MrUnknownDE's VCC Tools",
"id": "de.mrunknownde.vccrepo",
"url": "https://vcc.mrunk.de/index.json",
"author": "mrunknownde",
"packages": {
"de.mrunknownde.gittool": {
"versions": {
"1.0.1": {
"name": "de.mrunknownde.gittool",
"version": "1.0.1",
"displayName": "VRChat Git Control Tool",
"url": "https://github.com/MrUnknownDE/unity-gittool/archive/refs/tags/v1.0.1.zip",
"unity": "2022.3",
"description": "A lightweight, integrated Git panel for Unity."
},
"1.0.0": {
"name": "de.mrunknownde.gittool",
"version": "1.0.0",
"displayName": "VRChat Git Control Tool",
"url": "https://github.com/MrUnknownDE/unity-gittool/archive/refs/tags/v1.0.0.zip",
"unity": "2022.3",
"description": "A lightweight, integrated Git panel for Unity."
}
}
}
}
}

View File

@@ -1,12 +0,0 @@
{
"name": "de.mrunknownde.gittool",
"version": "1.0.0",
"displayName": "VRChat Git Control Tool",
"description": "A lightweight, integrated Git panel for Unity. Ideal for VRChat World/Avatar Creators to easily push commits directly from the editor to Gitea/GitHub/GitLab and other Git hosting services.",
"unity": "2022.3",
"author": {
"name": "mrunknownde"
},
"dependencies": {},
"vpmDependencies": {}
}