To find the real class name of the parent of a Unity object "button", you can use the GetType() method on the parent object itself. Here's an example:

var skillGetBtn = FindObjectsOfType<UIButton>(true).Where(r => r.name == "SkillGetBtn");
foreach (var button in skillGetBtn)
{
    var parentType = button.transform.parent.gameObject.GetType();
    Log($"button {button}, parent {parentType.Name}");
}

In this example, parentType.Name will give you the real class name of the parent object

var skillGetBtn = FindObjectsOfTypeUIButtontrueWherer = rname == SkillGetBtn;foreach var button in skillGetBtn Log$button button parent buttontransformparentgameObjectGetType; how to find the real cla

原文地址: https://www.cveoy.top/t/topic/hUbf 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录