From cd8e0372b63bb6feaaf053518013a641bc7e65ac Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Fri, 24 Jun 2022 09:30:08 +0900 Subject: [PATCH] fix: overlays do not exist in Unity 2019.2-2021.1 close #207, close #208 --- Scripts/Editor/UIParticleEditor.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Scripts/Editor/UIParticleEditor.cs b/Scripts/Editor/UIParticleEditor.cs index efff261..29f99d8 100644 --- a/Scripts/Editor/UIParticleEditor.cs +++ b/Scripts/Editor/UIParticleEditor.cs @@ -85,15 +85,21 @@ public override void OnGUI() static void Init() { #if !UNITY_2021_2_OR_NEWER - // static void Window(GUIContent title, WindowFunction sceneViewFunc, int order, UnityEngine.Object target, WindowDisplayOption option) var miSceneViewOverlayWindow = Type.GetType("UnityEditor.SceneViewOverlay, UnityEditor") .GetMethods(BindingFlags.Public | BindingFlags.Static) - .First(x => x.Name == "Window" && x.GetParameters().Length == 5); + .First(x => x.Name == "Window" && 5 <= x.GetParameters().Length); var windowFunction = (Action)WindowFunction; var windowFunctionType = Type.GetType("UnityEditor.SceneViewOverlay+WindowFunction, UnityEditor"); var windowFunctionDelegate = Delegate.CreateDelegate(windowFunctionType, windowFunction.Method); var windowTitle = new GUIContent(ObjectNames.NicifyVariableName(typeof(UIParticle).Name)); +#if UNITY_2019_2_OR_NEWER + //public static void Window(GUIContent title, WindowFunction sceneViewFunc, int order, Object target, WindowDisplayOption option, EditorWindow window = null) + var sceneViewArgs = new object[] { windowTitle, windowFunctionDelegate, 599, null, 2, null }; +#else + //public static void Window(GUIContent title, WindowFunction sceneViewFunc, int order, Object target, WindowDisplayOption option) var sceneViewArgs = new object[] { windowTitle, windowFunctionDelegate, 599, null, 2 }; +#endif + #if UNITY_2019_1_OR_NEWER SceneView.duringSceneGui += _ => miSceneViewOverlayWindow.Invoke(null, sceneViewArgs); #else