Last active
November 5, 2023 23:09
-
-
Save mikerochip/abec713f44e116e0cecbddef66d26a17 to your computer and use it in GitHub Desktop.
Unity Editor code to suppress annoying issues with commonly-used plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-nowarn:0618 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using HutongGames.PlayMakerEditor; | |
using UnityEditor; | |
namespace OrgName.ProjectName.Unity.Editor.AnnoyingStuff | |
{ | |
public class PluginSuppressor : AssetPostprocessor | |
{ | |
[InitializeOnLoadMethod] | |
private static void Initialize() | |
{ | |
SuppressPlayMakerAutoAddGUI(); | |
SuppressParrelSyncFeedbackScreen(); | |
} | |
private static void OnPostprocessAllAssets( | |
string[] importedAssets, | |
string[] deletedAssets, | |
string[] movedAssets, | |
string[] movedFromAssetPaths) | |
{ | |
// This is the best place to suppress the welcome screen because doing so has a side | |
// effect of creating an asset (EditorStartupPrefs.asset). You get an error if you | |
// create an asset in InitializeOnLoad "Unable to import newly created asset" | |
// Also, PlayMaker already has a hack in place to handle the welcome screen in a | |
// listener of EditorApplication.update (see PlayMakerEditorStartup class). | |
// OnPostprocessAllAssets() gets invoked before EditorApplication.update is invoked. | |
SuppressPlayMakerWelcomeScreen(); | |
} | |
private static void SuppressPlayMakerAutoAddGUI() | |
{ | |
FsmEditorSettings.AutoAddPlayMakerGUI = false; | |
// I'm calling EditorPrefs directly instead of FsmEditorSettings.SaveSettings() | |
// which would accomplish the same thing. The problem with that method is that it | |
// has a massive number of other settings that aren't necessary to touch here, so | |
// I'm trying to be more targeted at this specific setting. | |
EditorPrefs.SetBool("PlayMaker.AutoAddPlayMakerGUI", FsmEditorSettings.AutoAddPlayMakerGUI); | |
} | |
private static void SuppressPlayMakerWelcomeScreen() | |
{ | |
const string suppressorPlayMakerWelcomeKey = nameof(PluginSuppressor) + ".PlayMakerWelcomeScreen"; | |
if (SessionState.GetBool(suppressorPlayMakerWelcomeKey, false)) | |
return; | |
EditorStartupPrefs.ShowWelcomeScreen = false; | |
EditorStartupPrefs.WelcomeScreenVersion = PlayMakerWelcomeWindow.Version; | |
EditorStartupPrefs.ProjectUpdated(true); | |
SessionState.SetBool(suppressorPlayMakerWelcomeKey, true); | |
} | |
private static void SuppressParrelSyncFeedbackScreen() | |
{ | |
// see ParrelSync.NonCore.AskFeedbackDialog.StopShowingKey | |
EditorPrefs.SetBool("ParrelSync_StopShowFeedBack", true); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment