Skip to content

Commit

Permalink
fix: UnmaskRaycastFilter not working anymore
Browse files Browse the repository at this point in the history
close #29
  • Loading branch information
mob-sakai committed Oct 25, 2023
1 parent a276ef6 commit 14ab505
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Scripts/Editor/MenuOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ private static void CreateTutorialButton2(MenuCommand menuCommand)
unmask.fitTarget = button.transform as RectTransform;
unmask.fitOnLateUpdate = true;

var screen = unmaskedPanel.transform.Find("Screen").GetComponent<Image>();
screen.gameObject.AddComponent<UnmaskRaycastFilter>().targetUnmask = unmask;

Selection.activeGameObject = button.gameObject;
}

Expand All @@ -37,6 +34,12 @@ private static void CreateTransition(MenuCommand menuCommand)
Selection.activeGameObject = unmaskedPanel;
}

[MenuItem("GameObject/UI/Unmask/Unmasked Panel")]
private static GameObject CreateUnmaskedPanel(MenuCommand menuCommand)
{
return CreateUnmaskedPanel(AssetDatabase.GetBuiltinExtraResource<Sprite>("UI/Skin/UISprite.psd"), Image.Type.Sliced);
}

private static GameObject CreateUnmaskedPanel(Sprite unmaskSprite, Image.Type spriteType)
{
EditorApplication.ExecuteMenuItem("GameObject/UI/Panel");
Expand All @@ -51,6 +54,8 @@ private static GameObject CreateUnmaskedPanel(Sprite unmaskSprite, Image.Type sp
unmask.transform.SetParent(mask.transform);
unmask.GetComponent<Image>().sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>("UI/Skin/UISprite.psd");

mask.gameObject.AddComponent<UnmaskRaycastFilter>().targetUnmask = unmask;

var image = unmask.GetComponent<Image>();
image.sprite = unmaskSprite;
image.type = spriteType;
Expand All @@ -65,4 +70,4 @@ private static GameObject CreateUnmaskedPanel(Sprite unmaskSprite, Image.Type sp
return mask.gameObject;
}
}
}
}

0 comments on commit 14ab505

Please sign in to comment.