Skip to content

Instantly share code, notes, and snippets.

@sukedon
Last active June 17, 2018 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sukedon/eba11f6f4f48dbd82b1cabdbb200d069 to your computer and use it in GitHub Desktop.
Save sukedon/eba11f6f4f48dbd82b1cabdbb200d069 to your computer and use it in GitHub Desktop.
RaycastTargetをオフるやつ
using UnityEditor;
using UnityEngine.UI;
public static class RaycastTargetDisabler
{
[MenuItem("GameObject/Disable RaycastTarget", false, -1)]
public static void Disable()
{
var selected = Selection.activeGameObject;
if (!selected)
{
return;
}
var graphics = selected.GetComponentsInChildren <Graphic>(true);
foreach (var graphic in graphics)
{
if (!graphic.GetComponent <Button>())
{
graphic.raycastTarget = false;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment