Skip to content

Commit

Permalink
Gray-out ActivationToggle on irrelevant objects swiping
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-age committed Apr 10, 2021
1 parent d6e72cf commit b7c0556
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions Base/Controls/ActivationToggle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,37 @@ internal void DoActivationToggle(Rect rect, GameObject instance, bool isShown)

if (DoVerticalToggle(rect, instance.activeSelf, userData: instance, drawRect: drawRect, style: style))
{
var depth = GetTransformDepth(instance.transform);

if (depth != targetDepth)
return;

if (isSelectionBounded && !Selection.Contains(instance))
return;

draggedObjects.Add(instance);
Undo.RecordObject(instance, "GameObject Set Active");
instance.SetActive(!instance.activeSelf);
}
}


protected override void OnDraw(DrawArgs args)
{
using (new GUIColorScope(new Color(1, 1, 1, 0.5f), !args.isSwipeValid))
base.OnDraw(args);
}

protected override bool OnSwipeValidate(SwipeArgs args, GameObject instance)
{
if (targetState != args.isActive)
return false;

var depth = GetTransformDepth(instance.transform);

if (depth != targetDepth)
return false;

if (isSelectionBounded && !Selection.Contains(instance))
return false;

return true;
}

protected override void OnMouseDown(SwipeArgs args, GameObject instance)
{
targetState = args.isActive;
targetDepth = GetTransformDepth(instance.transform);

if (Selection.gameObjects.Length > 1 && Selection.Contains(instance))
Expand Down

0 comments on commit b7c0556

Please sign in to comment.