NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Character/Character.GameObject.cs

54 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Cysharp.Threading.Tasks;
using Gameplay.Emoji;
using Gameplay.Level;
using Gameplay.Performance;
using Gameplay.Unit;
using PhxhSDK;
using UnityEngine;
namespace Gameplay.Character
{
public partial class Character
{
public Transform leftHandTrans;
public Transform rightHandTrans;
public async UniTask CreateAsync()
{
var modelPath = runtimeData.configData.modelPath;
GameUnitManager.instance.RecordLoadPath(modelPath);
await AssetManager.Instance.PostPreload<GameObject>(modelPath);
var obj = Load(runtimeData.configData.modelPath);
PerformanceManager.instance.HandleCreateUnit(obj);
await _OnObjLoaded(obj);
}
private async UniTask _OnObjLoaded(GameObject obj)
{
var isEnemy = troopId != ETroopsId.Self;
// emoji 会替换outline所以要在emoji之后
OutlineManager.instance.AutoAddFromObj(obj, isEnemy);
leftHandTrans = Skeleton.GetBone("Grip_point02");
rightHandTrans = Skeleton.GetBone("Grip_point01");
cAnim = new CharacterAnim(this);
await cAnim.Init();
weapon = new Weapon.ViewWeapon(this);
}
protected override void UpdateGameObjectName()
{
SetName($"Character_{GetID()}");
// DebugUtil.Log(Node.GameObject.name);
}
protected override void OnDispose()
{
base.OnDispose();
SelecterView.Instance.UnSelect(Node);
}
}
}