修改VR适配问题
This commit is contained in:
parent
40de877779
commit
0f4143e7e8
@ -127,7 +127,7 @@ Material:
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.42352942, g: 0.7019608, b: 0.6784314, a: 0.25}
|
||||
- _Color: {r: 0.4235294, g: 0.7019608, b: 0.6784314, a: 0.25}
|
||||
- _Color: {r: 0.42352942, g: 0.7019608, b: 0.6784314, a: 0.25}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
||||
@ -118,7 +118,7 @@ Material:
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.8113208, g: 0.21813813, b: 0.22139741, a: 1}
|
||||
- _Color: {r: 0.8113207, g: 0.21813807, b: 0.22139737, a: 1}
|
||||
- _Color: {r: 0.8113208, g: 0.21813813, b: 0.22139741, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
||||
@ -116,7 +116,7 @@ Material:
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.028469002, g: 0.15428142, b: 0.343, a: 1}
|
||||
- _Color: {r: 0.028469002, g: 0.15428138, b: 0.34299996, a: 1}
|
||||
- _Color: {r: 0.028469002, g: 0.15428142, b: 0.343, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
8
Assets/_Scripts/Custom.meta
Normal file
8
Assets/_Scripts/Custom.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b9b8f11e76d72841a3faf4d640956bd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
Assets/_Scripts/Custom/ActiveStateSynchronizer.cs
Normal file
64
Assets/_Scripts/Custom/ActiveStateSynchronizer.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ActiveStateSynchronizer : MonoBehaviour
|
||||
{
|
||||
#if VR
|
||||
[Header("同步配置")]
|
||||
[Tooltip("拖入需要同步的目标父物体")]
|
||||
public Transform targetParent;
|
||||
bool isInit = false;
|
||||
void Update()
|
||||
{
|
||||
if (targetParent == null)
|
||||
{
|
||||
targetParent = GameObject.Find("SceneManager/niu/PTXZ")?.transform;
|
||||
}
|
||||
if (targetParent != null)
|
||||
{
|
||||
SynchronizeActiveStates(transform, targetParent);
|
||||
}
|
||||
}
|
||||
|
||||
private void SynchronizeActiveStates(Transform source, Transform target)
|
||||
{
|
||||
// 获取最小子物体数量以避免越界
|
||||
int minChildCount = Mathf.Min(source.childCount, target.childCount);
|
||||
|
||||
for (int i = 0; i < minChildCount; i++)
|
||||
{
|
||||
Transform sourceChild = source.GetChild(i);
|
||||
Transform targetChild = target.GetChild(i);
|
||||
|
||||
// 同步当前层级的激活状态
|
||||
if (sourceChild.gameObject.activeSelf != 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;
|
||||
}
|
||||
|
||||
}
|
||||
// 递归处理子层级
|
||||
SynchronizeActiveStates(sourceChild, targetChild);
|
||||
}
|
||||
|
||||
// 可选:处理子物体数量不一致的情况
|
||||
if (source.childCount != target.childCount)
|
||||
{
|
||||
Debug.LogWarning($"子物体数量不一致!源物体: {source.name}({source.childCount}) 目标物体: {target.name}({target.childCount})", this);
|
||||
}
|
||||
isInit = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
11
Assets/_Scripts/Custom/ActiveStateSynchronizer.cs.meta
Normal file
11
Assets/_Scripts/Custom/ActiveStateSynchronizer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: add14a4156b366340bb4a76d1dad5cb1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
x
Reference in New Issue
Block a user