29 lines
978 B
C#
29 lines
978 B
C#
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);
|
|
});
|
|
}
|
|
} |