ControlSheetRow hides property based on ShowIf etc

This commit is contained in:
Garry Newman
2025-12-01 16:21:22 +00:00
parent 87a6fde918
commit 8c1c752e81
3 changed files with 29 additions and 2 deletions

View File

@@ -34,8 +34,15 @@ public class ControlSheet : Panel, IControlSheet
if ( Target is null ) return;
var so = Game.TypeLibrary.GetSerializedObject( Target );
IControlSheet.FilterSortAndAdd( sheet, so.ToList() );
if ( Target is List<SerializedProperty> propertyList )
{
IControlSheet.FilterSortAndAdd( sheet, propertyList );
}
else
{
var so = Game.TypeLibrary.GetSerializedObject( Target );
IControlSheet.FilterSortAndAdd( sheet, so.ToList() );
}
}
int _hash;

View File

@@ -13,6 +13,8 @@ public class ControlSheetRow : Panel
Label _title;
Panel _right;
InspectorVisibilityAttribute[] _visibilityAttributes;
public ControlSheetRow()
{
_left = AddChild<Panel>( "left" );
@@ -24,6 +26,8 @@ public class ControlSheetRow : Panel
internal void Initialize( SerializedProperty prop )
{
Property = prop;
_visibilityAttributes = Property.GetAttributes<InspectorVisibilityAttribute>()?.ToArray();
}
protected override void OnParametersSet()
@@ -39,4 +43,15 @@ public class ControlSheetRow : Panel
if ( c is null ) return;
_right.AddChild( c );
}
public override void Tick()
{
base.Tick();
if ( _visibilityAttributes?.Length == 0 ) return;
if ( Property.Parent is null ) return;
bool hidden = _visibilityAttributes.All( x => x.TestCondition( Property.Parent ) );
SetClass( "hidden", hidden );
}
}

View File

@@ -5,6 +5,11 @@ ControlSheetRow
flex-shrink: 0;
max-height: 32px;
border-radius: 4px;
&.hidden
{
display: none;
}
}
ControlSheetRow > .left