+ option for when close scene
This commit is contained in:
@@ -3,6 +3,7 @@ using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using System.IO;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public static class DiscordSceneNotifier
|
||||
@@ -12,15 +13,55 @@ public static class DiscordSceneNotifier
|
||||
static DiscordSceneNotifier()
|
||||
{
|
||||
EditorSceneManager.sceneOpened += OnSceneOpened;
|
||||
EditorSceneManager.sceneClosed += OnSceneClosed;
|
||||
EditorApplication.quitting += OnEditorQuitting;
|
||||
}
|
||||
|
||||
private static void OnSceneOpened(UnityEngine.SceneManagement.Scene scene, UnityEditor.SceneManagement.OpenSceneMode mode)
|
||||
private static string GetUserName()
|
||||
{
|
||||
string userName = System.Environment.UserName;
|
||||
return System.Environment.UserName;
|
||||
}
|
||||
|
||||
private static string FormatPath(string path)
|
||||
{
|
||||
return path.Replace("Assets/", "");
|
||||
}
|
||||
|
||||
private static void OnSceneOpened(UnityEngine.SceneManagement.Scene scene, OpenSceneMode mode)
|
||||
{
|
||||
string user = GetUserName();
|
||||
string path = FormatPath(scene.path);
|
||||
|
||||
string message =
|
||||
$"🚧 **Scene Locked**\n" +
|
||||
$"👤 User: **{userName}**\n" +
|
||||
$"🎮 Scene: **{scene.path}**";
|
||||
$"🚧 **Scene Locked**\n" +
|
||||
$"👤 **{user}**\n" +
|
||||
$"📁 `{path}`";
|
||||
|
||||
SendDiscordMessage(message);
|
||||
}
|
||||
|
||||
private static void OnSceneClosed(UnityEngine.SceneManagement.Scene scene)
|
||||
{
|
||||
string user = GetUserName();
|
||||
string path = FormatPath(scene.path);
|
||||
|
||||
string message =
|
||||
$"🔓 **Scene Released**\n" +
|
||||
$"👤 **{user}**\n" +
|
||||
$"📁 `{path}`";
|
||||
|
||||
SendDiscordMessage(message);
|
||||
}
|
||||
|
||||
private static void OnEditorQuitting()
|
||||
{
|
||||
string user = GetUserName();
|
||||
|
||||
string message =
|
||||
$"❌ **Unity Closed**\n" +
|
||||
$"👤 **{user}**\n" +
|
||||
$"All scenes released";
|
||||
|
||||
SendDiscordMessage(message);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user