예제 #1
0
        static DiscordMain()
        {
            canBeEnabled   = EditorPrefs.GetBool("DarkRPC_EnableOnStartup", false);
            canShowProject = EditorPrefs.GetBool("DarkRPC_CanShowProject", true);
            canShowScene   = EditorPrefs.GetBool("DarkRPC_CanShowScene", true);
            if (canBeEnabled)
            {
                try
                {
                    Discord.EventHandlers handlers = new Discord.EventHandlers();
                    Discord.Initialize("594837567556550666", handlers);

                    EditorApplication.playmodeStateChanged           = HandleOnPlayModeChanged;
                    EditorSceneManager.activeSceneChangedInEditMode += EditorSceneManager_activeSceneChangedInEditMode;
                    Discord.RichPresence presence = new Discord.RichPresence();
                    if (canShowProject)
                    {
                        presence.details = "Project: " + GetProjectName();
                    }
                    else
                    {
                        presence.details = "Version: " + Application.unityVersion;
                    }
                    if (canShowScene)
                    {
                        presence.state = "Scene: " + EditorSceneManager.GetActiveScene().name;
                    }
                    else
                    {
                        presence.state = "DarkRPC adds an Discord RPC into Unity Editor...";
                    }
                    presence.startTimestamp = GetTimestamp(DateTime.Now);
                    presence.endTimestamp   = 0;
                    presence.largeImageKey  = "newicon";
                    Discord.UpdatePresence(presence);
                    Debug.Log("Discord RPC successfully started!");
                }
                catch
                {
                    Debug.LogError("Cannot initialize Discord RPC!");
                }
            }
        }
예제 #2
0
 private static void EditorSceneManager_activeSceneChangedInEditMode(Scene arg0, Scene arg1)
 {
     Discord.RichPresence presence = new Discord.RichPresence();
     if (canShowProject)
     {
         presence.details = "Project: " + GetProjectName();
     }
     else
     {
         presence.details = "Version: " + Application.unityVersion;
     }
     if (canShowScene)
     {
         presence.state = "Scene: " + EditorSceneManager.GetActiveScene().name;
     }
     else
     {
         presence.state = "DarkRPC adds an Discord RPC into Unity Editor...";
     }
     presence.largeImageKey = "newicon";
     Discord.UpdatePresence(presence);
 }
예제 #3
0
 static void HandleOnPlayModeChanged()
 {
     if (EditorApplication.isPaused)
     {
         Discord.RichPresence presence = new Discord.RichPresence();
         if (canShowProject)
         {
             presence.details = "Project: " + GetProjectName() + " (Paused)";
         }
         else
         {
             presence.details = "Version: " + Application.unityVersion;
         }
         if (canShowScene)
         {
             presence.state = "Scene: " + EditorSceneManager.GetActiveScene().name;
         }
         else
         {
             presence.state = "DarkRPC adds an Discord RPC into Unity Editor...";
         }
         presence.largeImageKey = "newicon";
         Discord.UpdatePresence(presence);
     }
     else if (EditorApplication.isPlaying)
     {
         Discord.RichPresence presence = new Discord.RichPresence();
         if (canShowProject)
         {
             presence.details = "Project: " + GetProjectName() + " (Playing)";
         }
         else
         {
             presence.details = "Version: " + Application.unityVersion;
         }
         if (canShowScene)
         {
             presence.state = "Scene: " + EditorSceneManager.GetActiveScene().name;
         }
         else
         {
             presence.state = "DarkRPC adds an Discord RPC into Unity Editor...";
         }
         presence.largeImageKey = "unityicon";
         Discord.UpdatePresence(presence);
     }
     else if (EditorApplication.isCompiling)
     {
         Discord.RichPresence presence = new Discord.RichPresence();
         if (canShowProject)
         {
             presence.details = "Project: " + GetProjectName() + " (Compiling)";
         }
         else
         {
             presence.details = "Version: " + Application.unityVersion;
         }
         if (canShowScene)
         {
             presence.state = "Scene: " + EditorSceneManager.GetActiveScene().name;
         }
         else
         {
             presence.state = "DarkRPC adds an Discord RPC into Unity Editor...";
         }
         presence.largeImageKey = "newicon";
         Discord.UpdatePresence(presence);
     }
 }