修复VR适配问题
This commit is contained in:
parent
0f4143e7e8
commit
1785664947
@ -7,7 +7,6 @@ public class ActiveStateSynchronizer : MonoBehaviour
|
|||||||
[Header("同步配置")]
|
[Header("同步配置")]
|
||||||
[Tooltip("拖入需要同步的目标父物体")]
|
[Tooltip("拖入需要同步的目标父物体")]
|
||||||
public Transform targetParent;
|
public Transform targetParent;
|
||||||
bool isInit = false;
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (targetParent == null)
|
if (targetParent == null)
|
||||||
@ -35,20 +34,18 @@ public class ActiveStateSynchronizer : MonoBehaviour
|
|||||||
{
|
{
|
||||||
sourceChild.gameObject.SetActive(targetChild.gameObject.activeSelf);
|
sourceChild.gameObject.SetActive(targetChild.gameObject.activeSelf);
|
||||||
}
|
}
|
||||||
if (isInit == false)
|
|
||||||
{
|
|
||||||
Toggle toggle;
|
|
||||||
Button btn;
|
|
||||||
if (sourceChild.TryGetComponent<Toggle>(out toggle) == true)
|
|
||||||
{
|
|
||||||
toggle.onValueChanged = targetChild.GetComponent<Toggle>().onValueChanged;
|
|
||||||
}
|
|
||||||
else if (sourceChild.TryGetComponent<Button>(out btn) == true)
|
|
||||||
{
|
|
||||||
btn.onClick = targetChild.GetComponent<Button>().onClick;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Toggle toggle;
|
||||||
|
Button btn;
|
||||||
|
if (sourceChild.TryGetComponent<Toggle>(out toggle) == true)
|
||||||
|
{
|
||||||
|
toggle.onValueChanged = targetChild.GetComponent<Toggle>().onValueChanged;
|
||||||
}
|
}
|
||||||
|
else if (sourceChild.TryGetComponent<Button>(out btn) == true)
|
||||||
|
{
|
||||||
|
btn.onClick = targetChild.GetComponent<Button>().onClick;
|
||||||
|
}
|
||||||
|
|
||||||
// 递归处理子层级
|
// 递归处理子层级
|
||||||
SynchronizeActiveStates(sourceChild, targetChild);
|
SynchronizeActiveStates(sourceChild, targetChild);
|
||||||
}
|
}
|
||||||
@ -58,7 +55,6 @@ public class ActiveStateSynchronizer : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Debug.LogWarning($"子物体数量不一致!源物体: {source.name}({source.childCount}) 目标物体: {target.name}({target.childCount})", this);
|
Debug.LogWarning($"子物体数量不一致!源物体: {source.name}({source.childCount}) 目标物体: {target.name}({target.childCount})", this);
|
||||||
}
|
}
|
||||||
isInit = true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user