Skip to content

editor helpers fix for 2021 #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions Assets/UXF/Scripts/Etc/Editor/EasyEventEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,17 @@ private static void ApplyEventDrawerPatch(bool enableOverride)

public static void ApplyEventPropertyDrawerPatch(bool forceApply = false)
{
#if UNITY_2021_1_OR_NEWER
// no need in Unity 2021
#else
EEESettings settings = GetEditorSettings();

if (!patchApplied || forceApply)
{
ApplyEventDrawerPatch(settings.overrideEventDrawer);
patchApplied = true;
}
#endif
}

public static EEESettings GetEditorSettings()
Expand Down Expand Up @@ -382,7 +386,7 @@ internal class SettingsGUIContent
public static void DrawSettingsButtons(EasyEventEditorHandler.EEESettings settings)
{
EditorGUI.indentLevel += 1;

//
settings.overrideEventDrawer = EditorGUILayout.ToggleLeft(enableToggleGuiContent, settings.overrideEventDrawer);

EditorGUI.BeginDisabledGroup(!settings.overrideEventDrawer);
Expand All @@ -403,6 +407,9 @@ public static void DrawSettingsButtons(EasyEventEditorHandler.EEESettings settin
// Using the IMGUI method
static class EasyEventEditorSettingsProvider
{
#if UNITY_2021_1_OR_NEWER
// no need in Unity 2021
#else
[SettingsProvider]
public static SettingsProvider CreateSettingsProvider()
{
Expand Down Expand Up @@ -430,11 +437,15 @@ public static SettingsProvider CreateSettingsProvider()

return provider;
}
#endif
}
#else
public class EasyEventEditorSettings : EditorWindow
{
#if UNITY_2021_1_OR_NEWER
// no need in Unity 2021
#else
[MenuItem("Edit/Easy Event Editor Settings")]
#endif
static void Init()
{
EasyEventEditorSettings window = GetWindow<EasyEventEditorSettings>(false, "EEE Settings");
Expand Down Expand Up @@ -917,7 +928,7 @@ MethodInfo InvokeFindMethod(string functionName, object targetObject, UnityEvent
findMethod = eventObject.GetType().GetMethod("FindMethod", BindingFlags.NonPublic | BindingFlags.Instance, null,
new System.Type[] {
typeof(string),
#if UNITY_2020_1_OR_NEWER
#if UNITY_2021_1_OR_NEWER
typeof(System.Type),
#else
typeof(object),
Expand All @@ -936,7 +947,7 @@ MethodInfo InvokeFindMethod(string functionName, object targetObject, UnityEvent
return null;
}

#if UNITY_2020_1_OR_NEWER
#if UNITY_2021_1_OR_NEWER
return findMethod.Invoke(eventObject, new object[] {functionName, targetObject?.GetType(), listenerMode, argType }) as MethodInfo;
#else
return findMethod.Invoke(eventObject, new object[] {functionName, targetObject, listenerMode, argType }) as MethodInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ protected void DrawPropertySortableArray(SerializedProperty property)
bool isStartProp = targetProp.propertyPath.StartsWith("m_");
using (new EditorGUI.DisabledScope(isStartProp))
{
EditorGUILayout.PropertyField(targetProp, targetProp.isExpanded);
EditorGUILayout.PropertyField(targetProp, true);
}
}
}
Expand Down