Skip to content

Commit 90a86c0

Browse files
committed
Merge pull request #65 from techno-dwarf-works/feature/refactoring
Version 0.0.62
1 parent 7360728 commit 90a86c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1257
-25
lines changed

Editor/Drawers/Container/ElementsContainer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public class ElementsContainer
1818
public SerializedObject SerializedObject => SerializedProperty.serializedObject;
1919
public SerializedProperty SerializedProperty { get; }
2020
public LabelContainer LabelContainer { get; }
21-
2221
public List<ContainerPrewarmElement> ContainersPrewarmChildren { get; }
2322

2423
public event Action<ElementsContainer> SerializedObjectChanged;

Editor/Drawers/HandlerBinding/Binding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Linq;
33
using System.Reflection;
44

5-
namespace Better.Commons.EditorAddons.Drawers.Handlers
5+
namespace Better.Commons.EditorAddons.Drawers.HandlerBinding
66
{
77
public class Binding
88
{

Editor/Drawers/HandlerBinding/BindingInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace Better.Commons.EditorAddons.Drawers
3+
namespace Better.Commons.EditorAddons.Drawers.HandlerBinding
44
{
55
public class BindingInfo
66
{

Editor/Drawers/HandlerBinding/Filters/AttributeHandlersFilter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
3+
using Better.Commons.EditorAddons.Drawers.Handlers;
44

5-
namespace Better.Commons.EditorAddons.Drawers.Handlers
5+
namespace Better.Commons.EditorAddons.Drawers.HandlerBinding.Filters
66
{
77
public class AttributeHandlersFilter : FieldHandlersFilter
88
{

Editor/Drawers/HandlerBinding/Filters/FieldHandlersFilter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
2+
using Better.Commons.EditorAddons.Drawers.Handlers;
23

3-
namespace Better.Commons.EditorAddons.Drawers.Handlers
4+
namespace Better.Commons.EditorAddons.Drawers.HandlerBinding.Filters
45
{
56
public class FieldHandlersFilter : HandlersFilter
67
{

Editor/Drawers/HandlerBinding/Filters/HandlersFilter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
using System.Collections.Generic;
22
using System.Linq;
3+
using Better.Commons.EditorAddons.Drawers.Handlers;
34

4-
namespace Better.Commons.EditorAddons.Drawers.Handlers
5+
namespace Better.Commons.EditorAddons.Drawers.HandlerBinding.Filters
56
{
67
public abstract class HandlersFilter
78
{

Editor/Drawers/HandlerBinding/HandlerBindingAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace Better.Commons.EditorAddons.Drawers
3+
namespace Better.Commons.EditorAddons.Drawers.HandlerBinding
44
{
55
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
66
public class HandlerBindingAttribute : Attribute

Editor/Drawers/HandlerBinding/HandlerBindingRegistry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Better.Commons.EditorAddons.Drawers.Handlers;
55
using Better.Commons.Runtime.Extensions;
66

7-
namespace Better.Commons.EditorAddons.Drawers
7+
namespace Better.Commons.EditorAddons.Drawers.HandlerBinding
88
{
99
public static class BindingRegistry
1010
{

Editor/Drawers/HandlerBinding/TypeHandlerBinder.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using Better.Commons.EditorAddons.Drawers.HandlerBinding.Filters;
5+
using Better.Commons.EditorAddons.Drawers.Handlers;
46
using Better.Commons.Runtime.Utility;
57

6-
namespace Better.Commons.EditorAddons.Drawers.Handlers
8+
namespace Better.Commons.EditorAddons.Drawers.HandlerBinding
79
{
810
public abstract class TypeHandlerBinder
911
{

Editor/Drawers/PropertyDrawer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using System.Reflection;
44
using Better.Commons.EditorAddons.Drawers.Base;
55
using Better.Commons.EditorAddons.Drawers.Container;
6+
using Better.Commons.EditorAddons.Drawers.HandlerBinding;
7+
using Better.Commons.EditorAddons.Drawers.HandlerBinding.Filters;
68
using Better.Commons.EditorAddons.Drawers.Handlers;
79
using Better.Commons.EditorAddons.Utility;
810
using Better.Commons.Runtime.Drawers.Attributes;

Editor/Drawers/Proxies.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Drawers/Proxies/FieldProxy.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Reflection;
2+
3+
namespace Better.Commons.EditorAddons.Drawers.Proxies
4+
{
5+
public class FieldProxy : InfoProxy
6+
{
7+
private readonly FieldInfo _info;
8+
private readonly object _instance;
9+
10+
public FieldProxy(FieldInfo info, object instance = null)
11+
: base(info.FieldType, info.Name)
12+
{
13+
_info = info;
14+
_instance = instance;
15+
}
16+
17+
public override object GetData()
18+
{
19+
return _info.GetValue(_instance);
20+
}
21+
22+
public override void SetData(object newData)
23+
{
24+
_info.SetValue(_instance, newData);
25+
}
26+
}
27+
}

Editor/Drawers/Proxies/FieldProxy.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Drawers/Proxies/InfoProxy.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
3+
namespace Better.Commons.EditorAddons.Drawers.Proxies
4+
{
5+
public abstract class InfoProxy
6+
{
7+
public Type Type { get; }
8+
public string Name { get; }
9+
10+
public event Action DataChanged;
11+
12+
public InfoProxy(Type type, string name)
13+
{
14+
Type = type;
15+
Name = name;
16+
}
17+
18+
//TODO: Add extension for GetData<> and TryGetData<>
19+
public abstract object GetData();
20+
21+
//TODO: Add extension for SetData<> and TrySetData<>
22+
public abstract void SetData(object newData);
23+
24+
public void SetDirty()
25+
{
26+
DataChanged?.Invoke();
27+
}
28+
}
29+
}

Editor/Drawers/Proxies/InfoProxy.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Reflection;
2+
using Better.Commons.Runtime.Extensions;
3+
4+
namespace Better.Commons.EditorAddons.Drawers.Proxies
5+
{
6+
public class ParameterProxy : SimpleProxy
7+
{
8+
public ParameterProxy(ParameterInfo info)
9+
: base(info.ParameterType, info.Name, info.HasDefaultValue ? info.DefaultValue : info.ParameterType.GetDefault())
10+
{
11+
}
12+
}
13+
}

Editor/Drawers/Proxies/ParameterProxy.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using UnityEngine.UIElements;
3+
4+
namespace Better.Commons.EditorAddons.Drawers.Proxies
5+
{
6+
public class ProxyViewFactory
7+
{
8+
public Func<Type, bool> SupportedFunc { get; }
9+
public Func<InfoProxy, VisualElement> CreateFunc { get; }
10+
11+
public ProxyViewFactory(Func<Type, bool> supportedFunc, Func<InfoProxy, VisualElement> createFunc)
12+
{
13+
SupportedFunc = supportedFunc;
14+
CreateFunc = createFunc;
15+
}
16+
}
17+
}

Editor/Drawers/Proxies/ProxyFactory.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using UnityEngine.UIElements;
4+
5+
namespace Better.Commons.EditorAddons.Drawers.Proxies
6+
{
7+
public static class ProxyFactoryExtensions
8+
{
9+
public static void Add(this List<ProxyViewFactory> self, Func<Type, bool> supportedFunc, Func<InfoProxy, VisualElement> createFunc)
10+
{
11+
var fieldFactory = new ProxyViewFactory(supportedFunc, createFunc);
12+
self.Add(fieldFactory);
13+
}
14+
}
15+
}

Editor/Drawers/Proxies/ProxyFactoryExtensions.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)