mirror of
https://github.com/MrUnknownDE/vcc-tools.git
synced 2026-04-19 15:03:47 +02:00
Compare commits
5 Commits
2cf94acaa5
...
49b1b6cd30
| Author | SHA1 | Date | |
|---|---|---|---|
| 49b1b6cd30 | |||
| ed40046c48 | |||
| 236a7562ec | |||
| 341073ef91 | |||
| c7d6aa4754 |
77
.github/workflows/release.yml
vendored
77
.github/workflows/release.yml
vendored
@@ -1,77 +0,0 @@
|
||||
name: VCC Release Automation
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*" # Startet bei v1.0.2, v1.1.0 etc.
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Extract Metadata
|
||||
id: metadata
|
||||
run: |
|
||||
VERSION=$(jq -r .version package.json)
|
||||
PKG_NAME=$(jq -r .name package.json)
|
||||
DISPLAY_NAME=$(jq -r .displayName package.json)
|
||||
DESCRIPTION=$(jq -r .description package.json)
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "pkg_name=$PKG_NAME" >> $GITHUB_OUTPUT
|
||||
echo "display_name=$DISPLAY_NAME" >> $GITHUB_OUTPUT
|
||||
echo "description=$DESCRIPTION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create VCC Package Zip
|
||||
run: |
|
||||
# Wir packen nur die relevanten Dateien ohne den Repo-Hauptordner
|
||||
zip -r ${{ steps.metadata.outputs.pkg_name }}-${{ github.ref_name }}.zip package.json README.md Editor/ Editor.meta package.json.meta README.md.meta
|
||||
|
||||
- name: Upload GitHub Release Asset
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: ${{ steps.metadata.outputs.pkg_name }}-${{ github.ref_name }}.zip
|
||||
generate_release_notes: true
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
- name: Update VCC Index
|
||||
run: |
|
||||
# Wechsel zum gh-pages Branch (oder erstelle ihn, falls er fehlt)
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
git fetch origin gh-pages || git checkout --orphan gh-pages
|
||||
git checkout gh-pages || git checkout -b gh-pages
|
||||
|
||||
# Falls die index.json noch nicht existiert, Basis-Struktur anlegen
|
||||
if [ ! -f index.json ]; then
|
||||
echo '{"name":"mrunknownde VCC Repo","id":"de.mrunknownde.vccrepo","url":"https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/index.json","author":"mrunknownde","packages":{}}' > index.json
|
||||
fi
|
||||
|
||||
# Neue Version in die index.json injizieren
|
||||
ZIP_URL="https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/${{ steps.metadata.outputs.pkg_name }}-${{ github.ref_name }}.zip"
|
||||
|
||||
jq --arg ver "${{ steps.metadata.outputs.version }}" \
|
||||
--arg name "${{ steps.metadata.outputs.pkg_name }}" \
|
||||
--arg disp "${{ steps.metadata.outputs.display_name }}" \
|
||||
--arg desc "${{ steps.metadata.outputs.description }}" \
|
||||
--arg url "$ZIP_URL" \
|
||||
'.packages[$name].versions[$ver] = {
|
||||
"name": $name,
|
||||
"version": $ver,
|
||||
"displayName": $disp,
|
||||
"description": $desc,
|
||||
"unity": "2022.3",
|
||||
"url": $url
|
||||
}' index.json > temp.json && mv temp.json index.json
|
||||
|
||||
git add index.json
|
||||
git commit -m "Add version ${{ github.ref_name }} to VCC index"
|
||||
git push origin gh-pages
|
||||
194
Editor/DiscordRPCPanel.cs
Normal file
194
Editor/DiscordRPCPanel.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
10
README.md
10
README.md
@@ -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.
|
||||
|
||||
52
index.json
52
index.json
@@ -1,52 +0,0 @@
|
||||
{
|
||||
"name": "MrUnknownDE's VCC Tools",
|
||||
"id": "de.mrunknownde.vcc-tools",
|
||||
"url": "https://vcc.mrunk.de/index.json",
|
||||
"author": "MrUnknownDE",
|
||||
"packages": {
|
||||
"de.mrunknownde.vcc-tools": {
|
||||
"versions": {
|
||||
"1.0.4": {
|
||||
"name": "de.mrunknownde.vcc-tools",
|
||||
"version": "1.0.4",
|
||||
"displayName": "MrUnknownDE's VRChat Tools",
|
||||
"url": "https://github.com/MrUnknownDE/vcc-tools/archive/refs/tags/v1.0.4.zip",
|
||||
"unity": "2022.3",
|
||||
"description": "A lightweight, integrated Git panel for Unity."
|
||||
},
|
||||
"1.0.3": {
|
||||
"name": "de.mrunknownde.vcc-tools",
|
||||
"version": "1.0.3",
|
||||
"displayName": "MrUnknownDE's VRChat Tools",
|
||||
"url": "https://github.com/MrUnknownDE/vcc-tools/archive/refs/tags/v1.0.3.zip",
|
||||
"unity": "2022.3",
|
||||
"description": "A lightweight, integrated Git panel for Unity."
|
||||
},
|
||||
"1.0.2": {
|
||||
"name": "de.mrunknownde.vcc-tools",
|
||||
"version": "1.0.2",
|
||||
"displayName": "MrUnknownDE's VRChat Tools",
|
||||
"url": "https://github.com/MrUnknownDE/vcc-tools/archive/refs/tags/v1.0.2.zip",
|
||||
"unity": "2022.3",
|
||||
"description": "A lightweight, integrated Git panel for Unity."
|
||||
},
|
||||
"1.0.1": {
|
||||
"name": "de.mrunknownde.vcc-tools",
|
||||
"version": "1.0.1",
|
||||
"displayName": "MrUnknownDE'sVRChat Tools",
|
||||
"url": "https://github.com/MrUnknownDE/vcc-tools/archive/refs/tags/v1.0.1.zip",
|
||||
"unity": "2022.3",
|
||||
"description": "A lightweight, integrated Git panel for Unity."
|
||||
},
|
||||
"1.0.0": {
|
||||
"name": "de.mrunknownde.vcc-tools",
|
||||
"version": "1.0.0",
|
||||
"displayName": "MrUnknownDE's VRChat Tools",
|
||||
"description": "A lightweight, integrated Git panel for Unity.",
|
||||
"unity": "2022.3",
|
||||
"url": "https://github.com/MrUnknownDE/vcc-tools/releases/download/v1.0.4/de.mrunknownde.vcc-tools-v1.0.4.zip"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
package.json
12
package.json
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"name": "de.mrunknownde.vcc-tools",
|
||||
"version": "1.0.0",
|
||||
"displayName": "MrUnknownDE's VRChat Tools",
|
||||
"description": "A lightweight, integrated Git panel for Unity.",
|
||||
"unity": "2022.3",
|
||||
"author": {
|
||||
"name": "MrUnknownDE"
|
||||
},
|
||||
"dependencies": {},
|
||||
"vpmDependencies": {}
|
||||
}
|
||||
Reference in New Issue
Block a user