private static void ApplySettings(UERPSettings settings) { UERP.showSceneName = settings.showSceneName; UERP.showProjectName = settings.showProjectName; UERP.resetOnSceneChange = settings.resetOnSceneChange; UERP.debugMode = settings.debugMode; if (UERP.debugMode) { UERP.Log("Applyed Settings from file"); } }
public static void GetSettings() { if (File.Exists(path)) { XmlSerializer serializer = new XmlSerializer(typeof(UERPSettings)); FileStream stream = new FileStream(path, FileMode.Open); UERPSettings settings = serializer.Deserialize(stream) as UERPSettings; ApplySettings(settings); stream.Close(); } }
public static void UpdateActivity() { if (debugMode) { Log("Updating Activity"); } if (discord == null) { Init(); } projectName = Application.productName; sceneName = EditorSceneManager.GetActiveScene().name; if (EditorApplication.isPlaying) { sceneName = "Playing: " + sceneName; } var activityManager = discord.GetActivityManager(); var activity = new Activity { State = showProjectName? projectName: "", Details = showSceneName? sceneName : "", Timestamps = { Start = lastTimestamp }, Assets = { LargeImage = "logo", LargeText = "Unity " + Application.unityVersion, SmallImage = "marshmello", SmallText = "UERP on Github", }, }; activityManager.UpdateActivity(activity, result => { if (result != Result.Ok) { LogError("Error from discord (" + result.ToString() + ")"); } else if (debugMode) { Log("Discord Result = " + result.ToString()); } }); UERPSettings.SaveSettings(); }
public static void SaveSettings() { UERPSettings settings = new UERPSettings(UERP.showSceneName, UERP.showProjectName, UERP.resetOnSceneChange, UERP.debugMode); XmlSerializer serializer = new XmlSerializer(typeof(UERPSettings)); var stream = new FileStream(path, FileMode.Create); serializer.Serialize(stream, settings); stream.Close(); if (UERP.debugMode) { UERP.Log("Saved Settings"); } }
public static void Init() { Log("Starting up..."); discord = new Discord.Discord(long.Parse(applicationId), (long)Discord.CreateFlags.Default); UERPSettings.GetSettings(); projectName = Application.productName; sceneName = EditorSceneManager.GetActiveScene().name; lastTimestamp = long.Parse(GetTimestamp()); UpdateActivity(); Log("Started!"); EditorApplication.update += Update; EditorSceneManager.sceneOpened += SceneOpened; EditorApplication.playModeStateChanged += PlayModeStateChanged; }