Project_WL/Assets/Script/Util/UI3DModel.cs

29 lines
978 B
C#
Raw Normal View History

2024-12-15 01:39:39 +00:00
using System;
using UnityEngine;
using UnityEngine.AI;
public class UI3DModel : MonoBehaviour
{
public Transform tf_model;
protected void Set_3DModel(string prefab, Action<Transform> act = null)
{
for (int i = 0; i < tf_model.childCount; i++)
Destroy(tf_model.GetChild(i).gameObject);
AddrResourceMgr.Ins.LoadObject<GameObject>(prefab, handle =>
{
var go = DSUtil.Get_Clone(handle.Result, tf_model);
if (DSUtil.CheckNull(go.GetComponent<AddressableReleaseSelf>()))
go.AddComponent<AddressableReleaseSelf>();
DSUtil.ChangeLayersRecursively(go.transform, "UI");
//Destroy(go.GetComponent<Actor>());
go.GetComponent<Actor>().Stop(true);
Destroy(go.GetComponent<BoxCollider>());
Destroy(go.GetComponent<NavMeshAgent>());
Destroy(go.GetComponent<Rigidbody>());
act?.Invoke(go.transform);
});
}
}