设置相机
This commit is contained in:
@@ -13,10 +13,9 @@ namespace NBF
|
||||
{
|
||||
public CameraShowMode Mode = CameraShowMode.None;
|
||||
|
||||
private CameraAsset _cameraAsset;
|
||||
[SerializeField] private CameraAsset _cameraAsset;
|
||||
private CameraShowMode _lastMode = CameraShowMode.None;
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_lastMode == Mode) return;
|
||||
@@ -30,7 +29,8 @@ namespace NBF
|
||||
//第一人称视角
|
||||
SetFPPCam();
|
||||
}
|
||||
_lastMode = Mode;
|
||||
|
||||
_lastMode = Mode;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,14 +42,15 @@ namespace NBF
|
||||
|
||||
private void SetFPPCam()
|
||||
{
|
||||
// var map = App.Main.GetComponent<Map>();
|
||||
// var unityComponent = map.SelfMapUnit.GetComponent<UnitUnityComponent>();
|
||||
// if (unityComponent != null)
|
||||
// {
|
||||
// _cameraAsset.fppVCam.LookAt = unityComponent.RootAsset.FppLook;
|
||||
// _cameraAsset.fppVCam.Follow = unityComponent.ModelAsset.NeckTransform;
|
||||
// unityComponent.ModelAsset.LookIk.solver.target = unityComponent.RootAsset.FppLook;
|
||||
// }
|
||||
var player = FPlayer.Instance;
|
||||
if (player != null)
|
||||
{
|
||||
_cameraAsset.fppVCam.LookAt = player.FppLook;
|
||||
_cameraAsset.fppVCam.Follow = player.ModelAsset.NeckTransform;
|
||||
// _cameraAsset.fppVCam.follow
|
||||
// _cameraAsset.fppVCam.ResolveFollow()
|
||||
player.ModelAsset.LookIk.solver.target = player.FppLook;
|
||||
}
|
||||
|
||||
_cameraAsset.fppVCam.Priority = 10;
|
||||
_cameraAsset.tppVCam.Priority = 0;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace NBF.Fishing2
|
||||
/// <returns></returns>
|
||||
public static GameObject CreatePlayer(Transform parent, string modelName = "Player")
|
||||
{
|
||||
var model = LoadPrefab($"Player/{modelName}", parent);
|
||||
var model = LoadPrefab($"Assets/ResRaw/Prefabs/Player/{modelName}.prefab", parent);
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
7
Assets/Scripts/Fishing/Player/FPlayer.Input.cs
Normal file
7
Assets/Scripts/Fishing/Player/FPlayer.Input.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace NBF
|
||||
{
|
||||
public class FPlayer_Input
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing/Player/FPlayer.Input.cs.meta
Normal file
3
Assets/Scripts/Fishing/Player/FPlayer.Input.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea2c2e2d4b4344f0bc9d58ba0aeec6fd
|
||||
timeCreated: 1766505279
|
||||
@@ -8,7 +8,7 @@ using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class FPlayer : MonoBehaviour
|
||||
public partial class FPlayer : MonoService<FPlayer>
|
||||
{
|
||||
public Transform Root;
|
||||
public Transform Eye;
|
||||
@@ -23,7 +23,7 @@ namespace NBF
|
||||
|
||||
public FPlayerData Data { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
protected override void OnAwake()
|
||||
{
|
||||
Character = gameObject.GetComponent<CharacterMovement>();
|
||||
FirstPerson = gameObject.GetComponent<FirstPersonCharacter>();
|
||||
@@ -48,72 +48,7 @@ namespace NBF
|
||||
RemoveInputEvent();
|
||||
}
|
||||
|
||||
#region Input
|
||||
|
||||
private void AddInputEvent()
|
||||
{
|
||||
InputManager.OnPlayerPerformed += OnPlayerCanceled;
|
||||
InputManager.OnPlayerPerformed += OnPlayerPerformed;
|
||||
|
||||
InputManager.OnPlayerValueCanceled += OnPlayerValueCanceled;
|
||||
InputManager.OnPlayerValuePerformed += OnPlayerValuePerformed;
|
||||
}
|
||||
|
||||
private void RemoveInputEvent()
|
||||
{
|
||||
InputManager.OnPlayerPerformed += OnPlayerCanceled;
|
||||
InputManager.OnPlayerPerformed += OnPlayerPerformed;
|
||||
|
||||
InputManager.OnPlayerValueCanceled += OnPlayerValueCanceled;
|
||||
InputManager.OnPlayerValuePerformed += OnPlayerValuePerformed;
|
||||
}
|
||||
|
||||
private void OnPlayerPerformed(string action)
|
||||
{
|
||||
if (action == InputDef.Player.Run)
|
||||
{
|
||||
Data.Run = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlayerCanceled(string action)
|
||||
{
|
||||
if (action == InputDef.Player.Run)
|
||||
{
|
||||
Data.Run = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlayerValueCanceled(InputAction.CallbackContext context)
|
||||
{
|
||||
var actionName = context.action.name;
|
||||
if (actionName == InputDef.Player.Move)
|
||||
{
|
||||
// var v2 = context.ReadValue<Vector2>();
|
||||
Data.MoveInput = Vector2.zero;
|
||||
// SendMoveMessage(v2, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlayerValuePerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
// var mapUnit = Parent as MapUnit;
|
||||
// Log.Info($"OnPlayerValuePerformed IsSelf={mapUnit.IsSelf()} id={mapUnit.Id}");
|
||||
var actionName = context.action.name;
|
||||
if (actionName == InputDef.Player.Move)
|
||||
{
|
||||
var v2 = context.ReadValue<Vector2>();
|
||||
Data.MoveInput = v2;
|
||||
// SendMoveMessage(v2, false);
|
||||
}
|
||||
else if (actionName == InputDef.Player.Look)
|
||||
{
|
||||
var v2 = context.ReadValue<Vector2>();
|
||||
// UpdatePlayerRotation(v2);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 角色模型
|
||||
|
||||
|
||||
@@ -11,5 +11,6 @@ namespace NBF
|
||||
public float RotationSpeed;
|
||||
|
||||
public Vector2 MoveInput;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ namespace NBF
|
||||
{
|
||||
public static Game Instance { get; private set; }
|
||||
|
||||
|
||||
|
||||
private static Scene _scene;
|
||||
public static Scene Main => _scene;
|
||||
|
||||
|
||||
@@ -162,6 +162,12 @@ namespace NBC.Asset.Editor
|
||||
assetData.Path = path;
|
||||
assetData.BundleName = asset.Bundle;
|
||||
assetData.Address = asset.Address;
|
||||
|
||||
if (!string.IsNullOrEmpty(asset.Tags))
|
||||
{
|
||||
//assetData.SetTags(asset.Tags.Split(","));
|
||||
}
|
||||
|
||||
_assets[path] = assetData;
|
||||
//没后缀的默认加入地址 .prefab
|
||||
var ext = Path.GetExtension(path);
|
||||
|
||||
Reference in New Issue
Block a user