Skip to content
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

Replace object[] with IEnumerable<object> #22

Merged
merged 1 commit into from
Jun 14, 2021
Merged
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
Replace object[] with IEnumerable<object>
ribbanya committed Jun 14, 2021
commit 744bca50d772c42b03d803856cca0001161dac61
5 changes: 3 additions & 2 deletions Assets/EasyButtons/Editor/Button.cs
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
using JetBrains.Annotations;
using UnityEditor;
using Utils;
using System.Collections.Generic;

/// <summary>
/// A class that holds information about a button and can draw it in the inspector.
@@ -36,7 +37,7 @@ protected Button(MethodInfo method, ButtonAttribute buttonAttribute)
_disabled = ! (buttonAttribute.Mode == ButtonMode.AlwaysEnabled || inAppropriateMode);
}

public void Draw(object[] targets)
public void Draw(IEnumerable<object> targets)
{
using (new EditorGUI.DisabledScope(_disabled))
{
@@ -63,6 +64,6 @@ internal static Button Create(MethodInfo method, ButtonAttribute buttonAttribute
}
}

protected abstract void DrawInternal(object[] targets);
protected abstract void DrawInternal(IEnumerable<object> targets);
}
}
3 changes: 2 additions & 1 deletion Assets/EasyButtons/Editor/ButtonWithParams.cs
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
using UnityEngine;
using Utils;
using Object = UnityEngine.Object;
using System.Collections.Generic;

internal class ButtonWithParams : Button
{
@@ -20,7 +21,7 @@ public ButtonWithParams(MethodInfo method, ButtonAttribute buttonAttribute, Para
_expanded = buttonAttribute.Expanded;
}

protected override void DrawInternal(object[] targets)
protected override void DrawInternal(IEnumerable<object> targets)
{
(Rect foldoutRect, Rect buttonRect) = DrawUtility.GetFoldoutAndButtonRects(DisplayName);

3 changes: 2 additions & 1 deletion Assets/EasyButtons/Editor/ButtonWithoutParams.cs
Original file line number Diff line number Diff line change
@@ -2,13 +2,14 @@
{
using System.Reflection;
using UnityEngine;
using System.Collections.Generic;

internal class ButtonWithoutParams : Button
{
public ButtonWithoutParams(MethodInfo method, ButtonAttribute buttonAttribute)
: base(method, buttonAttribute) { }

protected override void DrawInternal(object[] targets)
protected override void DrawInternal(IEnumerable<object> targets)
{
if ( ! GUILayout.Button(DisplayName))
return;
2 changes: 1 addition & 1 deletion Assets/EasyButtons/Editor/ButtonsDrawer.cs
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ public ButtonsDrawer(object target)
/// <summary>
/// Draws all the methods marked with <see cref="ButtonAttribute"/>.
/// </summary>
public void DrawButtons(object[] targets)
public void DrawButtons(IEnumerable<object> targets)
{
foreach (Button button in Buttons)
{