三国卡牌客户端基础资源仓库
yyl
2025-06-04 5fc16bcf94e8acec5a071535581376fe73173280
18 子 2D卡牌客户端搭建 / 2D卡牌客户端搭建
1个文件已修改
24 ■■■■■ 已修改文件
Assets/Editor/Tool/PrefabCreateTool.cs 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/Tool/PrefabCreateTool.cs
@@ -41,9 +41,33 @@
        // }
        instance.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one);
        // PrefabUtility.DisconnectPrefabInstance(instance);
        // 设置UI对象的Layer为UI
        instance.layer = LayerMask.NameToLayer("UI");
        // 递归设置所有子对象的Layer为UI
        foreach (Transform child in instance.transform)
        {
            SetLayerRecursively(child.gameObject, "UI");
        }
        Selection.activeGameObject = instance;
    }
    // 递归设置GameObject及其所有子对象的Layer
    private static void SetLayerRecursively(GameObject obj, string layerName)
    {
        if (obj == null)
            return;
        obj.layer = LayerMask.NameToLayer(layerName);
        foreach (Transform child in obj.transform)
        {
            SetLayerRecursively(child.gameObject, layerName);
        }
    }
    public static GameObject LoadUIPattern(string name)
    {
        return AssetDatabase.LoadAssetAtPath<GameObject>(string.Format("Assets/Editor/UIPattern/{0}.prefab", name));