Skip to content

Commit baf6c8b

Browse files
committed
corrections
1 parent b84ccfe commit baf6c8b

File tree

11 files changed

+32
-43
lines changed

11 files changed

+32
-43
lines changed

Code/Editor/Inspectors/ButtonedScriptEditor.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Reflection;
5-
using OlegHcp;
65
using OlegHcp.CSharp;
76
using OlegHcp.CSharp.Collections;
87
using OlegHcp.Inspector;
@@ -42,7 +41,7 @@ private void InitMethodList()
4241

4342
do
4443
{
45-
_methods.AddRange(GetMethods(targetType, mask));
44+
_methods.AddRange(EnumerateMethods(targetType, mask));
4645
targetType = targetType.BaseType;
4746
} while (targetType != ParentType);
4847
}
@@ -84,14 +83,13 @@ private void DrawButtons()
8483
}
8584
}
8685

87-
private static IEnumerable<Data> GetMethods(Type targetType, BindingFlags mask)
86+
private static IEnumerable<Data> EnumerateMethods(Type targetType, BindingFlags mask)
8887
{
8988
return targetType.GetMethods(mask)
9089
.Where(method => method.IsDefined(typeof(InspectorButtonAttribute)))
9190
.Select(method => new Data(method, method.GetCustomAttribute<InspectorButtonAttribute>()));
9291
}
9392

94-
#region entities
9593
private struct Data
9694
{
9795
public MethodInfo Method;
@@ -110,17 +108,18 @@ public void Deconstruct(out MethodInfo method, out InspectorButtonAttribute attr
110108
}
111109
}
112110

113-
[CustomEditor(typeof(MonoBehaviourExtended), true)]
114-
private class MonoBehaviourExtendedEditor : ButtonedScriptEditor
111+
[CustomEditor(typeof(MonoBehaviour), true, isFallback = true)]
112+
[CanEditMultipleObjects]
113+
private class MonoBehaviourEditor : ButtonedScriptEditor
115114
{
116115
protected override Type ParentType => typeof(MonoBehaviour);
117116
}
118117

119-
[CustomEditor(typeof(ScriptableObjectExtended), true)]
120-
private class ScriptableObjectExtendedEditor : ButtonedScriptEditor
118+
[CustomEditor(typeof(ScriptableObject), true, isFallback = true)]
119+
[CanEditMultipleObjects]
120+
private class ScriptableObjectEditor : ButtonedScriptEditor
121121
{
122122
protected override Type ParentType => typeof(ScriptableObject);
123123
}
124-
#endregion
125124
}
126125
}

Code/Runtime/OlegHcp/AbstractScripts.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.

Code/Runtime/OlegHcp/AbstractScripts.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

Code/Runtime/OlegHcp/Engine/UnityObjectExtensions.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ namespace OlegHcp.Engine
55
{
66
public static class UnityObjectExtensions
77
{
8-
public static bool HasHideFlag(this UnityObject self, HideFlags flag)
9-
{
10-
return (self.hideFlags & HideFlags.NotEditable) != 0;
11-
}
12-
138
/// <summary>
149
/// Destroys the unity object.
1510
/// </summary>
@@ -35,6 +30,21 @@ public static void Immortalize(this UnityObject self)
3530
UnityObject.DontDestroyOnLoad(self);
3631
}
3732

33+
public static bool HasHideFlag(this UnityObject self, HideFlags flag)
34+
{
35+
return (self.hideFlags & HideFlags.NotEditable) != 0;
36+
}
37+
38+
public static void AddHideFlag(this UnityObject self, HideFlags flag)
39+
{
40+
self.hideFlags |= flag;
41+
}
42+
43+
public static void RemoveHideFlag(this UnityObject self, HideFlags flag)
44+
{
45+
self.hideFlags &= ~flag;
46+
}
47+
3848
/// <summary>
3949
/// Returns true if the game object is asset reference. For scene objects returns false.
4050
/// </summary>

Code/Runtime/OlegHcp/Inspector/InspectorButtonAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using System;
2-
using UnityEngine;
32

43
namespace OlegHcp.Inspector
54
{
65
[AttributeUsage(AttributeTargets.Method)]
7-
public sealed class InspectorButtonAttribute : PropertyAttribute
6+
public sealed class InspectorButtonAttribute : Attribute
87
{
98
internal string ButtonName { get; private set; }
109
internal float Size { get; private set; } = 20f;

Code/Runtime/OlegHcp/Inspector/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ public class MyClass : MonoBehaviour
1616

1717
## InspectorButtonAttribute
1818

19-
In order to use InspectorButtonAttribute inherit class from 'MonoBehaviourExtended' or 'ScriptableObjectExtended'.
20-
2119
```csharp
2220
using System;
2321
using OlegHcp.Inspector;
2422
using UnityEngine;
2523

26-
public class ExampleClass : MonoBehaviourExtended
24+
public class ExampleClass : MonoBehaviour
2725
{
2826
[SerializeField]
2927
private string _text;

Code/Runtime/OlegHcp/SingleScripts/MonoSingleton.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
using System;
22
using OlegHcp.Engine;
33
using OlegHcp.Tools;
4+
using UnityEngine;
45

56
namespace OlegHcp.SingleScripts
67
{
78
/// <summary>
89
/// Represents implementation of MonoBehaviour singleton with lazy initialization.
910
/// </summary>
10-
public abstract class MonoSingleton<T> : MonoBehaviourExtended, IDisposable where T : MonoSingleton<T>
11+
public abstract class MonoSingleton<T> : MonoBehaviour, IDisposable where T : MonoSingleton<T>
1112
{
1213
private static T _instance;
1314

Code/Runtime/OlegHcp/SingleScripts/ScriptableSingleton.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
using OlegHcp.Tools;
2+
using UnityEngine;
23

34
namespace OlegHcp.SingleScripts
45
{
56
/// <summary>
67
/// Represents implementation of ScriptableObject singleton with lazy initialization.
78
/// </summary>
8-
public abstract class ScriptableSingleton<T> : ScriptableObjectExtended where T : ScriptableSingleton<T>
9+
public abstract class ScriptableSingleton<T> : ScriptableObject where T : ScriptableSingleton<T>
910
{
1011
private static T _instance;
1112

Code/Runtime/OlegHcp/SingleScripts/SingleBehaviour.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace OlegHcp.SingleScripts
99
/// Represents implementation of MonoBehaviour singleton. It has no dynamic creation of an instance.
1010
/// It should be saved in scene or should be created manually in runtime.
1111
/// </summary>
12-
public abstract class SingleBehaviour<T> : MonoBehaviourExtended, IDisposable where T : SingleBehaviour<T>
12+
public abstract class SingleBehaviour<T> : MonoBehaviour, IDisposable where T : SingleBehaviour<T>
1313
{
1414
private static T _instance;
1515

Code/Runtime/OlegHcp/SingleScripts/SingleScript.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace OlegHcp.SingleScripts
66
{
7-
public abstract class SingleScript<T> : ScriptableObjectExtended where T : SingleScript<T>
7+
public abstract class SingleScript<T> : ScriptableObject where T : SingleScript<T>
88
{
99
private static T _instance;
1010

0 commit comments

Comments
 (0)