Skip to content

Commit

Permalink
Merge pull request #33 from techno-dwarf-works/feature/refactoring
Browse files Browse the repository at this point in the history
Version 0.0.30
  • Loading branch information
uurha committed Aug 1, 2024
1 parent 96c69d4 commit 4e47dce
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 73 deletions.
23 changes: 0 additions & 23 deletions Editor/Drawers/BehavioredElements/GizmoElementBehaviour.cs

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions Editor/Drawers/BehavioredElements/SelectElementBehaviour.cs

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions Editor/Drawers/Container/ElementsContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ namespace Better.Commons.EditorAddons.Drawers.Container
{
public class ElementsContainer
{
private long _updateInterval = 5024;
private IVisualElementScheduledItem _updateSchedule;

public VisualElement RootElement { get; set; }
public PrewarmElement CoreElement { get; }
public bool Used { get; private set; }
Expand All @@ -26,16 +23,6 @@ public class ElementsContainer
public event Action<ElementsContainer> SerializedObjectChanged;
public event Action<ElementsContainer> SerializedPropertyChanged;

public long UpdateInterval
{
get => _updateInterval;
set
{
_updateInterval = Math.Max(value, 100);
_updateSchedule.Every(_updateInterval);
}
}

public ElementsContainer(SerializedProperty serializedProperty)
{
Used = false;
Expand Down
8 changes: 4 additions & 4 deletions Editor/Extensions/VisualElementExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ namespace Better.Commons.EditorAddons.Extensions
{
public static class VisualElementExtension
{
public static void OnElementAppear<TElement>(this VisualElement self, Action<TElement> action) where TElement : VisualElement
public static IVisualElementScheduledItem OnElementAppear<TElement>(this VisualElement self, Action<TElement> action) where TElement : VisualElement
{
self.OnElementAppear(self, action);
return self.OnElementAppear(self, action);
}

public static void AddClickedEvent(this VisualElement self, SerializedProperty property, EventCallback<ClickEvent, SerializedProperty> action)
{
self.RegisterCallback(action, property);
Expand All @@ -38,7 +38,7 @@ public static Image AddIcon(this VisualElement self, IconType iconType)
self.Insert(0, image);
return image;
}

public static Image AddIcon(this VisualElement self, Texture texture)
{
var image = VisualElementUtility.CreateLabelIcon(texture);
Expand Down
18 changes: 10 additions & 8 deletions Editor/Extensions/VisualElementSchedulerExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,30 @@ namespace Better.Commons.EditorAddons.Extensions
{
public static class VisualElementSchedulerExtension
{
public static void OnElementAppear<TElement>(this IVisualElementScheduler self, VisualElement element, Action<TElement> action)
public static IVisualElementScheduledItem OnElementAppear<TElement>(this IVisualElementScheduler self, VisualElement element, Action<TElement> action)
where TElement : VisualElement
{
if (self == null)
{
DebugUtility.LogException<ArgumentNullException>(nameof(self));
return;
throw new ArgumentNullException(nameof(self));
}

if (action == null)
{
DebugUtility.LogException<ArgumentNullException>(nameof(action));
return;
throw new ArgumentNullException(nameof(action));
}

self.Execute(OnExecute).Until(() => element.Q<TElement>() != null);
return;

return self.Execute(OnExecute).Until(() => element.Q<TElement>() != null);

void OnExecute()
{
var queriedElement = element.Q<TElement>();
if(queriedElement == null) return;
if (queriedElement == null)
{
return;
}

action.Invoke(queriedElement);
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.tdw.better.commons",
"displayName": "Better Commons",
"version": "0.0.29",
"version": "0.0.30",
"unity": "2021.3",
"description": " ",
"dependencies": {
Expand Down

0 comments on commit 4e47dce

Please sign in to comment.