修改框架
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a132d392d2a46354fac4a0c16cc6dac5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 相机控制器
|
||||
/// </summary>
|
||||
public abstract class CameraController : MonoBehaviour {
|
||||
/// <summary> 位置 </summary>
|
||||
public abstract Vector3 Position { get; set; }
|
||||
/// <summary> 正向 </summary>
|
||||
public abstract Vector3 Forward { get; set; }
|
||||
/// <summary> 右向 </summary>
|
||||
public abstract Vector3 Right { get; set; }
|
||||
/// <summary> 旋转 </summary>
|
||||
public abstract Vector3 EulerAngles { get; set; }
|
||||
/// <summary> 距离 </summary>
|
||||
public abstract float Distance { get; set; }
|
||||
|
||||
/// <summary> 初始化 </summary>
|
||||
public abstract void Initialize();
|
||||
/// <summary> 重置相机 </summary>
|
||||
public abstract void ResetCamera();
|
||||
|
||||
/// <summary> 屏幕坐标转换世界坐标 </summary>
|
||||
public virtual Vector3 ScreenToWorldPosition(Vector3 screenPosition) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96a98904bc59dd9468543e99e52f3d94
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2408eae033f1fe54ebf17cdc3530f985
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 默认相机
|
||||
/// </summary>
|
||||
public class CameraDefault : CameraController {
|
||||
|
||||
public override Vector3 Position {
|
||||
get => throw new System.NotImplementedException();
|
||||
set => throw new System.NotImplementedException();
|
||||
}
|
||||
public override Vector3 Forward {
|
||||
get => throw new System.NotImplementedException();
|
||||
set => throw new System.NotImplementedException();
|
||||
}
|
||||
public override Vector3 Right {
|
||||
get => throw new System.NotImplementedException();
|
||||
set => throw new System.NotImplementedException();
|
||||
}
|
||||
public override Vector3 EulerAngles {
|
||||
get => throw new System.NotImplementedException();
|
||||
set => throw new System.NotImplementedException();
|
||||
}
|
||||
public override float Distance {
|
||||
get => throw new System.NotImplementedException();
|
||||
set => throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Initialize() {
|
||||
ModuleCamera.OnCameraMode += ModuleCamera_OnCameraMode;
|
||||
}
|
||||
|
||||
private void ModuleCamera_OnCameraMode(EnumCameraMode mode) {
|
||||
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
|
||||
return;
|
||||
#endif
|
||||
gameObject.SetActive(mode == EnumCameraMode.None);
|
||||
if (mode == EnumCameraMode.None) { ModuleCamera.CurrentCamera = this; }
|
||||
}
|
||||
|
||||
public override void ResetCamera() {
|
||||
// transform.position = HotUpdateScene.I.StartPoint.position;
|
||||
// transform.eulerAngles = HotUpdateScene.I.StartPoint.eulerAngles;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f6f4a232485de9439914dc14b7df5a7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 移轴相机
|
||||
/// </summary>
|
||||
public class CameraMoveAxis : CameraController {
|
||||
|
||||
public Camera mainCamera;
|
||||
public LayerMask layerMask;
|
||||
|
||||
private RaycastHit hitInfo;
|
||||
|
||||
public override Vector3 Position {
|
||||
get => transform.position;
|
||||
set => transform.position = value;
|
||||
}
|
||||
public override Vector3 Forward {
|
||||
get => throw new System.NotImplementedException();
|
||||
set => throw new System.NotImplementedException();
|
||||
}
|
||||
public override Vector3 Right {
|
||||
get => throw new System.NotImplementedException();
|
||||
set => throw new System.NotImplementedException();
|
||||
}
|
||||
public override Vector3 EulerAngles {
|
||||
get => transform.eulerAngles;
|
||||
set => transform.eulerAngles = value;
|
||||
}
|
||||
public override float Distance {
|
||||
get => GetVisualField();
|
||||
set => SetVisualField(value);
|
||||
}
|
||||
|
||||
private float GetVisualField() {
|
||||
return Vector3.Distance(mainCamera.transform.localPosition, Vector3.zero);
|
||||
}
|
||||
private void SetVisualField(float value) {
|
||||
value = Mathf.Clamp(value, 10, 30);
|
||||
Vector3 direction = mainCamera.transform.localPosition - Vector3.zero;
|
||||
mainCamera.transform.localPosition = direction.normalized * value;
|
||||
// if (!Volume.profile.TryGet(out DepthOfField depthOfField)) { return; }
|
||||
// depthOfField.focusDistance.SetValue(new FloatParameter(value));
|
||||
}
|
||||
|
||||
public override void Initialize() {
|
||||
ModuleCamera.OnCameraMode += ModuleCamera_OnCameraMode;
|
||||
}
|
||||
|
||||
private void ModuleCamera_OnCameraMode(EnumCameraMode mode) {
|
||||
gameObject.SetActive(mode == EnumCameraMode.MoveAxis);
|
||||
if (mode == EnumCameraMode.MoveAxis) { ModuleCamera.CurrentCamera = this; }
|
||||
}
|
||||
|
||||
public override void ResetCamera() {
|
||||
// transform.position = HotUpdateScene.I.StartPoint.position;
|
||||
// transform.eulerAngles = HotUpdateScene.I.StartPoint.eulerAngles;
|
||||
}
|
||||
|
||||
public override Vector3 ScreenToWorldPosition(Vector3 screenPosition) {
|
||||
Ray ray = mainCamera.ScreenPointToRay(screenPosition);
|
||||
Physics.Raycast(ray, out hitInfo, 200f, layerMask);
|
||||
Vector3 position = Vector3.zero;
|
||||
if (hitInfo.transform != null) { position = hitInfo.point; }
|
||||
return position;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc9103ac1c158bb41af1ba45de4f9d08
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 相机模块
|
||||
/// </summary>
|
||||
public class ModuleCamera : ModuleSingle<ModuleCamera> {
|
||||
/// <summary> 当前相机 </summary>
|
||||
public static CameraController CurrentCamera;
|
||||
/// <summary> 相机模式事件 </summary>
|
||||
public static event Action<EnumCameraMode> OnCameraMode;
|
||||
/// <summary> 设置相机模式 </summary>
|
||||
public static void Mode(EnumCameraMode mode, bool isReset = true) {
|
||||
OnCameraMode?.Invoke(mode);
|
||||
if (isReset) { I.ResetCamera(); }
|
||||
}
|
||||
|
||||
public List<CameraController> cameras;
|
||||
|
||||
protected override void Awake() => NoReplace();
|
||||
|
||||
private void Start() => cameras.ForEach(obj => obj.Initialize());
|
||||
|
||||
/// <summary> 重置相机 </summary>
|
||||
public void ResetCamera() => cameras.ForEach(obj => obj.ResetCamera());
|
||||
|
||||
/// <summary>
|
||||
/// 转换方向
|
||||
/// </summary>
|
||||
/// <param name="forward">相机的前方</param>
|
||||
/// <param name="right">相机的右方</param>
|
||||
/// <param name="moveInput">输入的移动方向</param>
|
||||
/// <returns>Y轴向上的平面移动方向</returns>
|
||||
public static Vector3 TransferDirection(Vector3 forward, Vector3 right, Vector2 moveInput) {
|
||||
// 确保前方和右方方向在水平面上
|
||||
forward.y = 0;
|
||||
right.y = 0;
|
||||
|
||||
// 归一化方向向量
|
||||
forward.Normalize();
|
||||
right.Normalize();
|
||||
|
||||
// 计算移动方向
|
||||
return (forward * moveInput.y + right * moveInput.x).normalized;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d436e33934b1feb4d8a3909ffb5292a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da2e7bba0b4252e4fbe87dc9d280d2e9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
/// <summary>
|
||||
/// 基础输入
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(PlayerInput))]
|
||||
public class InputBasic : MonoBehaviour {
|
||||
public Vector3 mousePosition;
|
||||
|
||||
#region 输入系统
|
||||
/// <summary> 鼠标位置 </summary>
|
||||
public void OnMousePosition(InputValue inputValue) {
|
||||
mousePosition = inputValue.Get<Vector2>();
|
||||
ModuleInput.mousePosition = mousePosition;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efd8b69b2d3f913448202357a1a084ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 输入模块
|
||||
/// </summary>
|
||||
public class ModuleInput : ModuleSingle<ModuleInput> {
|
||||
|
||||
/// <summary> 当前输入模式 </summary>
|
||||
public static EnumInputMode inputMode;
|
||||
/// <summary> 鼠标指针位置 </summary>
|
||||
public static Vector3 mousePosition;
|
||||
/// <summary> 转换模式事件 </summary>
|
||||
public static event Action<EnumInputMode> OnInputMode;
|
||||
/// <summary> 临时禁用事件 </summary>
|
||||
public static event Action<bool> OnTemporarilyDisable;
|
||||
|
||||
private static bool isPointerOverUIObject;// 指针是否在UI上
|
||||
|
||||
/// <summary> 指针是否在UI上 </summary>
|
||||
public static bool IsPointerOverUIObject => isPointerOverUIObject;
|
||||
|
||||
/// <summary> 设置输入模式 </summary>
|
||||
public static void Mode(EnumInputMode mode) {
|
||||
inputMode = mode;
|
||||
OnInputMode?.Invoke(mode);
|
||||
}
|
||||
/// <summary> 临时禁用输入 </summary>
|
||||
public static void TemporarilyDisable(bool value) => OnTemporarilyDisable?.Invoke(value);
|
||||
|
||||
protected override void Awake() => NoReplace();
|
||||
|
||||
private void Update() {
|
||||
#if UNITY_STANDALONE
|
||||
//电脑平台
|
||||
isPointerOverUIObject = EventSystem.current.IsPointerOverGameObject();
|
||||
#elif UNITY_WEBGL
|
||||
//WebGL平台
|
||||
isPointerOverUIObject = EventSystem.current.IsPointerOverGameObject();
|
||||
#elif UNITY_ANDROID
|
||||
//安卓平台
|
||||
isPointerOverUIObject = EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId);
|
||||
#elif UNITY_IOS
|
||||
//苹果平台
|
||||
isPointerOverUIObject = EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0535501d69413b6439c33f5b9809d359
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7bb6d05c681dd0c4bb87381b7c7862ae
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 可视化生成器
|
||||
/// </summary>
|
||||
public abstract class VisualGenerator<T> : MonoBehaviour {
|
||||
|
||||
/// <summary> 更新可视化内容 </summary>
|
||||
public abstract void CreateVisual(ref T visual, Transform original);
|
||||
/// <summary> 释放可视化内容 </summary>
|
||||
public abstract void ReleaseVisual(T visual);
|
||||
|
||||
/// <summary> 创建可视化内容 </summary>
|
||||
public static Type Create<Type>(Transform original, Transform parent) {
|
||||
Transform temp = Instantiate(original, parent);
|
||||
temp.gameObject.SetActive(true);
|
||||
return temp.GetComponent<Type>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29a91fefa7bcfe24da30d8514a51d25e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 155db3b2435c1314492a3e51d1e9b711
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user