添加帮助类
parent
423c0d4633
commit
0c8cbe9329
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7b3afab971ec1794fb300420a7212e53
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,82 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace ZC
|
||||||
|
{
|
||||||
|
public static class CommonHelper
|
||||||
|
{
|
||||||
|
public static T FindChildDeep<T>(this Transform self, string name) where T : Object
|
||||||
|
{
|
||||||
|
Transform findDeep = null;
|
||||||
|
FindDeep(self, name, ref findDeep);
|
||||||
|
if (findDeep == null)
|
||||||
|
{
|
||||||
|
Debug.LogError("未找到此组件");
|
||||||
|
}
|
||||||
|
|
||||||
|
var component = findDeep.GetComponent<T>();
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void FindDeep(Transform tran, string name, ref Transform transform)
|
||||||
|
{
|
||||||
|
if (tran.name == name)
|
||||||
|
{
|
||||||
|
transform = tran;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < tran.childCount; i++)
|
||||||
|
{
|
||||||
|
FindDeep(tran.GetChild(i), name, ref transform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<T> FindChildDeeps<T>(this Transform self) where T : Object
|
||||||
|
{
|
||||||
|
List<T> list = new List<T>();
|
||||||
|
FindDeeps(self, ref list);
|
||||||
|
if (list.Count <= 0)
|
||||||
|
{
|
||||||
|
Debug.LogError("未找到此组件");
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void FindDeeps<T>(Transform tran, ref List<T> list)
|
||||||
|
{
|
||||||
|
var component = tran.GetComponent<T>();
|
||||||
|
if (component != null)
|
||||||
|
list.Add(component);
|
||||||
|
|
||||||
|
for (var i = 0; i < tran.childCount; i++)
|
||||||
|
{
|
||||||
|
FindDeeps(tran.GetChild(i), ref list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断是否在某个物体范围内(范围型判断,超出返回false)
|
||||||
|
/// 基于MeshRender的实现方式
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tran"></param>
|
||||||
|
/// <param name="self"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsInRangeAutoFix(Transform tran, Transform self)
|
||||||
|
{
|
||||||
|
var meshRenderer = tran.GetComponent<MeshRenderer>();
|
||||||
|
|
||||||
|
Bounds rendererBounds = self.GetComponent<MeshRenderer>().bounds;
|
||||||
|
Bounds colliderBounds = meshRenderer.bounds;
|
||||||
|
bool rendererIsInsideBox = colliderBounds.Intersects(rendererBounds);
|
||||||
|
|
||||||
|
return rendererIsInsideBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ChangeProcedure(ProcedureType procedureType)
|
||||||
|
{
|
||||||
|
// ZCGame.ProcedureManager.ChangeProcedure(procedureType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5bc4f7c26faa46b98ff244d747c4394a
|
||||||
|
timeCreated: 1712048369
|
|
@ -0,0 +1,31 @@
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace ZC
|
||||||
|
{
|
||||||
|
public static class UniTaskHelper
|
||||||
|
{
|
||||||
|
public static async UniTask WaitFinish(string isFinish)
|
||||||
|
{
|
||||||
|
Debug.Log("000000000000000");
|
||||||
|
while (isFinish == "none")
|
||||||
|
{
|
||||||
|
Debug.Log("111111111111111");
|
||||||
|
await UniTask.Yield();
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Log("22222222222222222");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async UniTask LoadingSceneAsync(string sceneName)
|
||||||
|
{
|
||||||
|
await UniTask.Delay(1000);
|
||||||
|
|
||||||
|
// var ui = ZCGame.UIManager.ShowUI(UIType.LoadingUI);
|
||||||
|
// var loadingUI = ui as LoadingUI;
|
||||||
|
//
|
||||||
|
// await ResourcesLocalComponent.Instance.LoadSceneAsync(sceneName, callback: loadingUI.UpdateSlider);
|
||||||
|
// ZCGame.UIManager.HideUI(UIType.LoadingUI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cd953cadd6584d679bdbe60bf38be040
|
||||||
|
timeCreated: 1719126488
|
Loading…
Reference in New Issue