48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using Fantasy.Async;
|
|
using NBC;
|
|
using Fantasy.Entitas;
|
|
using Fantasy.Entitas.Interface;
|
|
using RootMotion.FinalIK;
|
|
using UnityEngine;
|
|
|
|
namespace NBF.Fishing2
|
|
{
|
|
/// <summary>
|
|
/// Unit 对应的unity对象组件
|
|
/// </summary>
|
|
public class UnitUnityComponent : Entity
|
|
{
|
|
public GameObject GameObject { get; set; }
|
|
|
|
public Transform Transform { get; set; }
|
|
|
|
public PlayerAsset Asset { get; set; }
|
|
|
|
public async FTask InitUnityObject()
|
|
{
|
|
var gameObject = PrefabsHelper.CreatePlayer(SceneSettings.Instance.Node);
|
|
GameObject = gameObject;
|
|
Transform = gameObject.transform;
|
|
Transform.localPosition = new Vector3(484, 1, 422);
|
|
Asset = gameObject.GetComponent<PlayerAsset>();
|
|
Parent.GetOrAddComponent<FlashlightComponent>();
|
|
Parent.GetOrAddComponent<CharacterControllerComponent>();
|
|
}
|
|
|
|
|
|
public class UnitUnityComponentDestroySystem : DestroySystem<UnitUnityComponent>
|
|
{
|
|
protected override void Destroy(UnitUnityComponent self)
|
|
{
|
|
if (self.GameObject != null)
|
|
{
|
|
Object.Destroy(self.GameObject);
|
|
}
|
|
|
|
self.Asset = null;
|
|
self.GameObject = null;
|
|
self.Transform = null;
|
|
}
|
|
}
|
|
}
|
|
} |