mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 00:08:51 -05:00
Move HorizontalGroup to core package
This commit is contained in:
parent
d9b3c97f6d
commit
1fc608985b
@ -11,53 +11,7 @@ namespace TriInspector.GroupDrawers
|
||||
{
|
||||
public override TriPropertyCollectionBaseElement CreateElement(DeclareHorizontalGroupAttribute attribute)
|
||||
{
|
||||
return new TriBoxGroupElement();
|
||||
}
|
||||
|
||||
private class TriBoxGroupElement : TriPropertyCollectionBaseElement
|
||||
{
|
||||
public override float GetHeight(float width)
|
||||
{
|
||||
if (ChildrenCount == 0)
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
var height = 0f;
|
||||
|
||||
for (var i = 0; i < ChildrenCount; i++)
|
||||
{
|
||||
var child = GetChild(i);
|
||||
var childWidth = width / ChildrenCount;
|
||||
var childHeight = child.GetHeight(childWidth);
|
||||
|
||||
height = Mathf.Max(height, childHeight);
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position)
|
||||
{
|
||||
if (ChildrenCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var childWidth = position.width / ChildrenCount;
|
||||
|
||||
for (var i = 0; i < ChildrenCount; i++)
|
||||
{
|
||||
var child = GetChild(i);
|
||||
var childRect = new Rect(position)
|
||||
{
|
||||
width = childWidth,
|
||||
x = position.x + i * childWidth,
|
||||
};
|
||||
|
||||
child.OnGUI(childRect);
|
||||
}
|
||||
}
|
||||
return new TriHorizontalGroupElement();
|
||||
}
|
||||
}
|
||||
}
|
50
Editor/Elements/TriHorizontalGroupElement.cs
Normal file
50
Editor/Elements/TriHorizontalGroupElement.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TriInspector.Elements
|
||||
{
|
||||
public class TriHorizontalGroupElement : TriPropertyCollectionBaseElement
|
||||
{
|
||||
public override float GetHeight(float width)
|
||||
{
|
||||
if (ChildrenCount == 0)
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
var height = 0f;
|
||||
|
||||
for (var i = 0; i < ChildrenCount; i++)
|
||||
{
|
||||
var child = GetChild(i);
|
||||
var childWidth = width / ChildrenCount;
|
||||
var childHeight = child.GetHeight(childWidth);
|
||||
|
||||
height = Mathf.Max(height, childHeight);
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position)
|
||||
{
|
||||
if (ChildrenCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var childWidth = position.width / ChildrenCount;
|
||||
|
||||
for (var i = 0; i < ChildrenCount; i++)
|
||||
{
|
||||
var child = GetChild(i);
|
||||
var childRect = new Rect(position)
|
||||
{
|
||||
width = childWidth,
|
||||
x = position.x + i * childWidth,
|
||||
};
|
||||
|
||||
child.OnGUI(childRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
Editor/Elements/TriHorizontalGroupElement.cs.meta
Normal file
3
Editor/Elements/TriHorizontalGroupElement.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e609cf56a7e242d8b9cb5813178a7e69
|
||||
timeCreated: 1642259149
|
Loading…
Reference in New Issue
Block a user