1
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
using BigSpace.Logic;
|
||||
using BigSpace.XRCore.Event;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -27,14 +25,14 @@ public class GrabItem : MonoBehaviour
|
||||
float runTime = 0;
|
||||
|
||||
//<2F><>ʱ<EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ֵĶ<D6B5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>
|
||||
bool isRun2 = false;
|
||||
bool isRun2 = false;
|
||||
float waitTime2 = 1f;
|
||||
float runTime2 = 0;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_rig = GetComponent<Rigidbody>();
|
||||
if (effectHideAndShowCtr == null)
|
||||
if(effectHideAndShowCtr == null)
|
||||
effectHideAndShowCtr = GetComponent<EffectHideAndShowCtr>();
|
||||
m_originParent = transform.parent;
|
||||
startPosition = this.transform.localPosition;
|
||||
@@ -45,7 +43,7 @@ public class GrabItem : MonoBehaviour
|
||||
{
|
||||
if (isRun)
|
||||
{
|
||||
|
||||
|
||||
runTime += Time.deltaTime;
|
||||
if (runTime >= waitTime)
|
||||
{
|
||||
@@ -110,14 +108,12 @@ public class GrabItem : MonoBehaviour
|
||||
{
|
||||
if (other.gameObject.CompareTag("RightHand"))
|
||||
{
|
||||
SceneMgr.Instance.isTrigger = true;
|
||||
//Debug.Log("Ent<6E><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:"+other.gameObject.name);
|
||||
//if (m_catch == null)
|
||||
m_catch = other.GetComponent<CatchManager>();
|
||||
m_catch = other.GetComponent<CatchManager>();
|
||||
SetTriggerParameter("DisTrigger");
|
||||
// GlobalEventMgr.Dispatch(GameEvent.EventRayEnd2);
|
||||
if (m_catch == null) return;
|
||||
// Debug.Log("111<31>Ƿ<EFBFBD><C7B7><EFBFBD>ʼ:"+ m_catch.Start);
|
||||
// Debug.Log("111<31>Ƿ<EFBFBD><C7B7><EFBFBD>ʼ:"+ m_catch.Start);
|
||||
if (m_catch.Start)
|
||||
{
|
||||
isRun = false;
|
||||
@@ -132,15 +128,6 @@ public class GrabItem : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.gameObject.CompareTag("RightHand"))
|
||||
{
|
||||
SceneMgr.Instance.isTrigger = false;
|
||||
//GlobalEventMgr.Dispatch(GameEvent.EventRayEnd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnTriggerStay(Collider other)
|
||||
{
|
||||
@@ -148,7 +135,8 @@ public class GrabItem : MonoBehaviour
|
||||
{
|
||||
//Debug.Log("Stay<61><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"+ other.gameObject.name);
|
||||
//if (m_catch == null)
|
||||
m_catch = other.GetComponent<CatchManager>();
|
||||
m_catch = other.GetComponent<CatchManager>();
|
||||
|
||||
if (m_catch == null) return;
|
||||
//Debug.Log("222<32>Ƿ<EFBFBD><C7B7><EFBFBD>ʼ:" + m_catch.Start);
|
||||
if (m_catch.Start)
|
||||
@@ -175,7 +163,7 @@ public class GrabItem : MonoBehaviour
|
||||
|
||||
private void SetStartPosition()
|
||||
{
|
||||
this.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
||||
this.transform.localRotation = new Quaternion(0,0,0,0);
|
||||
this.transform.localPosition = startPosition;
|
||||
}
|
||||
|
||||
@@ -183,7 +171,7 @@ public class GrabItem : MonoBehaviour
|
||||
{
|
||||
if (this.GetComponent<UpDownMovement>() != null)
|
||||
{
|
||||
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>:" + isMove);
|
||||
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>:"+isMove);
|
||||
this.GetComponent<UpDownMovement>().isMove = isMove;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,22 @@ public class LeavePlayPrefabControll : MonoBehaviour
|
||||
|
||||
private void GameDataManage_EventShowLeavePlayByPosition(Vector3 v3)
|
||||
{
|
||||
Debug.Log("<EFBFBD>Լ<EFBFBD><EFBFBD>뿪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>:" + v3);
|
||||
Debug.Log("自己离开出界位置:" + v3);
|
||||
//string index = boxName.Replace("LeaveBoxCollider_", "");
|
||||
GameDataManage.Instance.isShowLeaveOn = true;
|
||||
RenderSettings.fog = false;
|
||||
GameObject gameScene = GameObject.Find("GameScene");
|
||||
gameScene.transform.Find("Static").gameObject.SetActive(false);
|
||||
gameScene.transform.Find("Dynamic").gameObject.SetActive(false);
|
||||
//GameObject gameScene = GameObject.Find("GameScene");
|
||||
//GameObject staticObj = gameScene.transform.Find("Static").gameObject;
|
||||
//gameScene.transform.Find("Static").gameObject.SetActive(false);
|
||||
//Renderer[] renderers = staticObj.GetComponentsInChildren<Renderer>();
|
||||
//for (int i = 0; i < renderers.Length-1; i++)
|
||||
//{
|
||||
// renderers[i].enabled = false;
|
||||
//}
|
||||
//gameScene.transform.Find("Dynamic").gameObject.SetActive(false);
|
||||
|
||||
SetObjsRender(false);
|
||||
|
||||
GameObject gameEnvi = GameObject.Find("GameScene/Environment/SkyBox_360Player");
|
||||
SetGameObjectLayer(gameEnvi, false);
|
||||
leavePrefab.transform.position = new Vector3(v3.x, 0, v3.z);
|
||||
@@ -36,17 +45,18 @@ public class LeavePlayPrefabControll : MonoBehaviour
|
||||
//block.SetActive(true);
|
||||
}
|
||||
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//主动检测出界
|
||||
private void GameDataManage_EventShowCheckLeavePlay(int index)
|
||||
{
|
||||
Debug.Log("<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>:" + index);
|
||||
Debug.Log("显示的位置:" + index);
|
||||
GameDataManage.Instance.isShowLeaveOn = true;
|
||||
RenderSettings.fog = false;
|
||||
GameObject gameScene = GameObject.Find("GameScene");
|
||||
gameScene.transform.Find("Static").gameObject.SetActive(false);
|
||||
gameScene.transform.Find("Dynamic").gameObject.SetActive(false);
|
||||
//GameObject gameScene = GameObject.Find("GameScene");
|
||||
//gameScene.transform.Find("Static").gameObject.SetActive(false);
|
||||
//gameScene.transform.Find("Dynamic").gameObject.SetActive(false);
|
||||
SetObjsRender(false);
|
||||
GameObject SkyBox = GameObject.Find("GameScene/Environment/SkyBox_360Player");
|
||||
SetGameObjectLayer(SkyBox, false);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>㼶ΪInvisible
|
||||
SetGameObjectLayer(SkyBox, false);//修改天空球显示层级为Invisible
|
||||
GameObject tagObj = GameObject.Find("LeaveBoxCollider_" + index+ "/StartPosition");
|
||||
leavePrefab.transform.position = new Vector3(tagObj.transform.position.x, 0, tagObj.transform.position.z);
|
||||
|
||||
@@ -55,19 +65,136 @@ public class LeavePlayPrefabControll : MonoBehaviour
|
||||
//block.SetActive(true);
|
||||
}
|
||||
|
||||
public void SetObjsRender(bool isActive)
|
||||
{
|
||||
GameObject gameScene = GameObject.Find("GameScene");
|
||||
GameObject staticObj = gameScene.transform.Find("Static").gameObject;
|
||||
// 使用递归方法获取所有子物体的Renderer组件
|
||||
List<Renderer> staticRenderers = GetAllRenderersRecursive(staticObj);
|
||||
for (int i = 0; i < staticRenderers.Count; i++)
|
||||
{
|
||||
staticRenderers[i].enabled = isActive;
|
||||
}
|
||||
|
||||
GameObject dynamicObj = gameScene.transform.Find("Dynamic").gameObject;
|
||||
// 使用递归方法获取所有子物体的Renderer组件
|
||||
List<Renderer> dynamicRenderers = GetAllRenderersRecursive(dynamicObj);
|
||||
for (int i = 0; i < dynamicRenderers.Count; i++)
|
||||
{
|
||||
dynamicRenderers[i].enabled = isActive;
|
||||
}
|
||||
|
||||
// 处理名字包含"vfx"的节点,隐藏或恢复
|
||||
SetVfxNodesActive(staticObj, isActive);
|
||||
SetVfxNodesActive(dynamicObj, isActive);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归设置名字包含"vfx"的节点的激活状态(隐藏或恢复)
|
||||
/// </summary>
|
||||
/// <param name="parent">父物体</param>
|
||||
/// <param name="isActive">是否激活(true=恢复,false=隐藏)</param>
|
||||
private void SetVfxNodesActive(GameObject parent, bool isActive)
|
||||
{
|
||||
if (parent == null) return;
|
||||
|
||||
// 递归遍历所有子物体
|
||||
SetVfxNodesActiveRecursive(parent.transform, isActive);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归辅助方法,查找并设置名字包含"vfx"的节点
|
||||
/// </summary>
|
||||
private void SetVfxNodesActiveRecursive(Transform parent, bool isActive)
|
||||
{
|
||||
if (parent == null) return;
|
||||
|
||||
// 检查当前节点名字是否包含"vfx"(不区分大小写)
|
||||
if (parent.name.ToLower().Contains("vfx"))
|
||||
{
|
||||
parent.gameObject.SetActive(isActive);
|
||||
}
|
||||
|
||||
// 递归遍历所有子物体
|
||||
foreach (Transform child in parent)
|
||||
{
|
||||
SetVfxNodesActiveRecursive(child, isActive);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归获取GameObject及其所有子物体的Renderer组件(包括子物体的子物体,直到没有子物体)
|
||||
/// </summary>
|
||||
/// <param name="parent">父物体</param>
|
||||
/// <param name="includeInactive">是否包含未激活的物体</param>
|
||||
/// <returns>所有Renderer组件的列表</returns>
|
||||
public List<Renderer> GetAllRenderersRecursive(GameObject parent, bool includeInactive = false)
|
||||
{
|
||||
List<Renderer> renderers = new List<Renderer>();
|
||||
|
||||
if (parent == null) return renderers;
|
||||
|
||||
// 递归遍历所有子物体
|
||||
GetAllRenderersRecursive(parent.transform, renderers, includeInactive);
|
||||
|
||||
return renderers;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归辅助方法,遍历Transform层级结构
|
||||
/// </summary>
|
||||
private void GetAllRenderersRecursive(Transform parent, List<Renderer> renderers, bool includeInactive)
|
||||
{
|
||||
if (parent == null) return;
|
||||
|
||||
// 如果物体未激活且不包含未激活物体,则跳过
|
||||
if (!includeInactive && !parent.gameObject.activeInHierarchy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否有碰撞器或触发器,如果有则跳过该节点,保持原状
|
||||
Collider collider = parent.GetComponent<Collider>();
|
||||
if (collider != null)
|
||||
{
|
||||
// 如果节点上有碰撞器或触发器,跳过该节点的Renderer,继续遍历子物体
|
||||
foreach (Transform child in parent)
|
||||
{
|
||||
GetAllRenderersRecursive(child, renderers, includeInactive);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取当前物体的Renderer组件
|
||||
Renderer renderer = parent.GetComponent<Renderer>();
|
||||
if (renderer != null)
|
||||
{
|
||||
renderers.Add(renderer);
|
||||
}
|
||||
|
||||
// 递归遍历所有子物体
|
||||
foreach (Transform child in parent)
|
||||
{
|
||||
GetAllRenderersRecursive(child, renderers, includeInactive);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void GameDataManage_EventHideLeavePlay()
|
||||
{
|
||||
Debug.Log("<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
Debug.Log("到位置了还原回来");
|
||||
GameDataManage.Instance.isShowLeaveOn = false;
|
||||
RenderSettings.fog = true;
|
||||
GameObject gameScene = GameObject.Find("GameScene");
|
||||
// GameObject gameScene = GameObject.Find("GameScene");
|
||||
if (GameDataManage.Instance.isNeedShowAnyBuyOffline)
|
||||
{
|
||||
gameScene.transform.Find("Static").gameObject.SetActive(true);
|
||||
gameScene.transform.Find("Dynamic").gameObject.SetActive(true);
|
||||
//gameScene.transform.Find("Static").gameObject.SetActive(true);
|
||||
//gameScene.transform.Find("Dynamic").gameObject.SetActive(true);
|
||||
SetObjsRender(true);
|
||||
}
|
||||
GameObject SkyBox = GameObject.Find("GameScene/Environment/SkyBox_360Player");
|
||||
SetGameObjectLayer(SkyBox, true);//<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>㼶ΪDefault
|
||||
SetGameObjectLayer(SkyBox, true);//恢复天空球显示层级为Default
|
||||
|
||||
leavePrefab.SetActive(false);
|
||||
//block.SetActive(false);
|
||||
@@ -76,7 +203,7 @@ public class LeavePlayPrefabControll : MonoBehaviour
|
||||
}
|
||||
|
||||
|
||||
//<EFBFBD><EFBFBD>GameObject<EFBFBD><EFBFBD>Layer <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ùر<EFBFBD>Invisible<EFBFBD>㼶<EFBFBD><EFBFBD>ʾ
|
||||
//修改GameObject的Layer 需要相机设置关闭Invisible层级显示
|
||||
private void SetGameObjectLayer(GameObject go, bool isShow)
|
||||
{
|
||||
if (go == null) return;
|
||||
|
||||
@@ -50,13 +50,13 @@ public class PlayJiaGuAnimator : MonoBehaviour
|
||||
}
|
||||
}
|
||||
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
|
||||
[SerializeField] private List<Animator> childAnimator; // ֱ<><D6B1><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD><EFBFBD>
|
||||
[SerializeField] private List<GameObject> childAnimator; // ֱ<><D6B1><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
public void SetTriggerParameter(string parameterName)
|
||||
{
|
||||
for (int i = 0; i < childAnimator.Count; i++)
|
||||
{
|
||||
childAnimator[i].SetTrigger(parameterName);
|
||||
Destroy(childAnimator[i]);
|
||||
}
|
||||
}
|
||||
private void OnTriggerEnter(Collider other)
|
||||
|
||||
@@ -53,12 +53,23 @@ public class SingleTouchPlayAnimator : MonoBehaviour
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
[SerializeField] private GameObject Vfx;
|
||||
[SerializeField] private GameObject Vfx1;
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.gameObject.name == "PalmBox_L" || other.gameObject.name == "PalmBox_R")
|
||||
{
|
||||
SetTriggerParameter("DisTrigger");
|
||||
if (Vfx != null)
|
||||
{
|
||||
Destroy(Vfx);
|
||||
Vfx = null;
|
||||
}
|
||||
if (Vfx1 != null)
|
||||
{
|
||||
Destroy(Vfx1);
|
||||
Vfx1 = null;
|
||||
}
|
||||
animator.Play("Touch");
|
||||
animatorpig.Play("Touch");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user