Skip to content

Commit

Permalink
Merge pull request #34 from techno-dwarf-works/feature/refactoring
Browse files Browse the repository at this point in the history
Version 0.0.31
  • Loading branch information
uurha authored Aug 2, 2024
2 parents a2132ce + 801ce2f commit 762ab7c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Better.Commons.EditorAddons.Drawers.BehavioredElements
public class DefaultElementBehaviour<TElement> : IElementBehaviour<TElement> where TElement : VisualElement, new()
{
protected BehavioredElement<TElement> BehavioredElement { get; private set; }

public virtual void OnLink(BehavioredElement<TElement> behavioredElement)
{
BehavioredElement = behavioredElement;
Expand All @@ -19,20 +19,23 @@ public virtual void OnLink(BehavioredElement<TElement> behavioredElement)
.MarginTop(zeroLength)
.Width(new StyleLength(new Length(100, LengthUnit.Percent)));
}

public virtual void OnAttach(VisualElement root)
{
if (root is not Label label)
{
label = root.Q<Label>();
}

var labelParent = label?.parent;
if (labelParent == null) return;
if (labelParent.Contains(BehavioredElement)) return;

BehavioredElement.RemoveFromHierarchy();
label.style
.Width(StyleDefinition.LabelWidthStyle)
.FlexGrow(new StyleFloat(1f));

var labelParent = label.parent;

labelParent.style.FlexDirection(new StyleEnum<FlexDirection>(FlexDirection.Row));
labelParent.Add(BehavioredElement);

Expand Down
2 changes: 1 addition & 1 deletion Assets/BetterCommons/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.30",
"version": "0.0.31",
"unity": "2021.3",
"description": " ",
"dependencies": {
Expand Down

0 comments on commit 762ab7c

Please sign in to comment.