修复VR适配问题

This commit is contained in:
shenjianxing 2025-04-02 17:40:35 +08:00
parent 0f4143e7e8
commit 1785664947

View File

@ -7,7 +7,6 @@ public class ActiveStateSynchronizer : MonoBehaviour
[Header("同步配置")]
[Tooltip("拖入需要同步的目标父物体")]
public Transform targetParent;
bool isInit = false;
void Update()
{
if (targetParent == null)
@ -35,8 +34,7 @@ public class ActiveStateSynchronizer : MonoBehaviour
{
sourceChild.gameObject.SetActive(targetChild.gameObject.activeSelf);
}
if (isInit == false)
{
Toggle toggle;
Button btn;
if (sourceChild.TryGetComponent<Toggle>(out toggle) == true)
@ -48,7 +46,6 @@ public class ActiveStateSynchronizer : MonoBehaviour
btn.onClick = targetChild.GetComponent<Button>().onClick;
}
}
// 递归处理子层级
SynchronizeActiveStates(sourceChild, targetChild);
}
@ -58,7 +55,6 @@ public class ActiveStateSynchronizer : MonoBehaviour
{
Debug.LogWarning($"子物体数量不一致!源物体: {source.name}({source.childCount}) 目标物体: {target.name}({target.childCount})", this);
}
isInit = true;
}
#endif
}