-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using HierarchyLabels; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using Component = UnityEngine.Component; | ||
|
||
[Serializable, | ||
DisplayName("Missing Raycaster on Canvas"), | ||
Description("Shows a label if a Canvas is attached but no GraphicalRaycaster is present or it is disabled.")] | ||
public class CanvasWithoutRaycastHierarchyLabelRule : HierarchyLabelRule | ||
{ | ||
[SerializeField] private bool _includeDisabled; | ||
|
||
public override bool GetLabel(Component component, out string label) | ||
{ | ||
label = string.Empty; | ||
|
||
if (component is Canvas && IsRaycastDisabledOrMissing(component)) | ||
{ | ||
label = "Missing GraphicRaycaster!"; | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
private bool IsRaycastDisabledOrMissing(Component component) | ||
{ | ||
return !component.GetComponent<GraphicRaycaster>() || | ||
_includeDisabled && !component.GetComponent<GraphicRaycaster>().enabled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters