调整目录结构
This commit is contained in:
3
Assets/Scripts/Model/Assets.meta
Normal file
3
Assets/Scripts/Model/Assets.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a18bd4a09c14040b9ea1de796d645f1
|
||||
timeCreated: 1743783137
|
||||
12
Assets/Scripts/Model/Assets/BaitAsset.cs
Normal file
12
Assets/Scripts/Model/Assets/BaitAsset.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 鱼饵
|
||||
/// </summary>
|
||||
public class BaitAsset : PreviewableAsset
|
||||
{
|
||||
public Transform hook;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Assets/BaitAsset.cs.meta
Normal file
3
Assets/Scripts/Model/Assets/BaitAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 524c26f472e74fa1ad167db68e562324
|
||||
timeCreated: 1743824319
|
||||
80
Assets/Scripts/Model/Assets/BobberAsset.cs
Normal file
80
Assets/Scripts/Model/Assets/BobberAsset.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 浮漂资产
|
||||
/// </summary>
|
||||
public class BobberAsset : PreviewableAsset
|
||||
{
|
||||
public Transform body;
|
||||
public Transform stick;
|
||||
|
||||
/// <summary>
|
||||
/// 顶部连接点
|
||||
/// </summary>
|
||||
public Transform topConnector;
|
||||
|
||||
/// <summary>
|
||||
/// 底部连接点
|
||||
/// </summary>
|
||||
public Transform bottomConnector;
|
||||
|
||||
/// <summary>
|
||||
/// 水线
|
||||
/// </summary>
|
||||
public Transform waterline;
|
||||
|
||||
|
||||
// "previewRotationEnabled": 0,
|
||||
// "previewRotation": {
|
||||
// "x": 0.0,
|
||||
// "y": 0.0,
|
||||
// "z": 0.0
|
||||
// },
|
||||
//
|
||||
// "idleAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 2768973905596830902
|
||||
// },
|
||||
// "swimAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 7205922588037503814
|
||||
// },
|
||||
// "accelerateAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 5473833867069321029
|
||||
// },
|
||||
// "turnLeftAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 0
|
||||
// },
|
||||
// "turnRightAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 0
|
||||
// },
|
||||
// "shake1Animation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 748440419864685152
|
||||
// },
|
||||
// "shake2Animation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 748440419864685152
|
||||
// },
|
||||
// "shake3Animation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 748440419864685152
|
||||
// },
|
||||
// "StuffedAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 0
|
||||
// },
|
||||
// "useRendererBounds": 0,
|
||||
// "overrideLengthAxis": 0,
|
||||
// "lengthAxis": 0,
|
||||
// "applyLengthFactor": 0,
|
||||
// "lengthFactor": 0.0,
|
||||
// "useStuffedAnim": 0,
|
||||
// "stuffedFrameTime": 0.0
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Assets/BobberAsset.cs.meta
Normal file
3
Assets/Scripts/Model/Assets/BobberAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e885da772834bb289c2368be2f6eb5b
|
||||
timeCreated: 1743824616
|
||||
14
Assets/Scripts/Model/Assets/FishAsset.cs
Normal file
14
Assets/Scripts/Model/Assets/FishAsset.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FishAsset : PreviewableAsset
|
||||
{
|
||||
public Transform root;
|
||||
|
||||
/// <summary>
|
||||
/// 弯曲节点
|
||||
/// </summary>
|
||||
public Transform[] spines;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Assets/FishAsset.cs.meta
Normal file
3
Assets/Scripts/Model/Assets/FishAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c12ba26d0bd74238ab26aee49ef6fd5d
|
||||
timeCreated: 1743824172
|
||||
18
Assets/Scripts/Model/Assets/FishGroupAsset.cs
Normal file
18
Assets/Scripts/Model/Assets/FishGroupAsset.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class FishGroupAsset : MonoBehaviour
|
||||
{
|
||||
// "previewRotationEnabled": 0,
|
||||
// "previewRotation": {
|
||||
// "x": 0.0,
|
||||
// "y": 0.0,
|
||||
// "z": 0.0
|
||||
// },
|
||||
// "previewFitVertical": 1,
|
||||
// "smallFishName": "ostrea_ed_o",
|
||||
// "mediumFishName": "ostrea_ed_o",
|
||||
// "largeFishName": "ostrea_ed_o"
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Assets/FishGroupAsset.cs.meta
Normal file
3
Assets/Scripts/Model/Assets/FishGroupAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e9e67584f094dcbba9e61f37a55a5b4
|
||||
timeCreated: 1743824179
|
||||
12
Assets/Scripts/Model/Assets/HookAsset.cs
Normal file
12
Assets/Scripts/Model/Assets/HookAsset.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class HookAsset : PreviewableAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 鱼饵挂点
|
||||
/// </summary>
|
||||
public Transform baitConnector;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Assets/HookAsset.cs.meta
Normal file
3
Assets/Scripts/Model/Assets/HookAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6eea50c041f42d5bd95d9e56c3a9c6f
|
||||
timeCreated: 1743824134
|
||||
8
Assets/Scripts/Model/Assets/LineAsset.cs
Normal file
8
Assets/Scripts/Model/Assets/LineAsset.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class LineAsset : PreviewableAsset
|
||||
{
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Assets/LineAsset.cs.meta
Normal file
3
Assets/Scripts/Model/Assets/LineAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8059c6be171e47edb0390fa091285100
|
||||
timeCreated: 1743824214
|
||||
20
Assets/Scripts/Model/Assets/LureAsset.cs
Normal file
20
Assets/Scripts/Model/Assets/LureAsset.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class LureAsset : PreviewableAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 鱼钩挂点
|
||||
/// </summary>
|
||||
public Transform[] hookPoints;
|
||||
|
||||
[Tooltip("maksymalny kąt odchylenia przynetu przy sciaganiu, rotacja w osi Y")]
|
||||
public float rotateVeloMaxAngle = 10f;
|
||||
|
||||
[Tooltip("predkosc odchylenia przynetu przy sciaganiu, rotacja w osi Y")]
|
||||
public float rotateVeloMaxSpeed = 3f;
|
||||
|
||||
public Vector3 rotationInFishJaw = Vector3.zero;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Assets/LureAsset.cs.meta
Normal file
3
Assets/Scripts/Model/Assets/LureAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 897c0165284148879a9d158ea8010a15
|
||||
timeCreated: 1743824269
|
||||
19
Assets/Scripts/Model/Assets/PreviewableAsset.cs
Normal file
19
Assets/Scripts/Model/Assets/PreviewableAsset.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 可以3D预览的资产
|
||||
/// </summary>
|
||||
public class PreviewableAsset : MonoBehaviour
|
||||
{
|
||||
[Tooltip("默认位置")] public Vector3 position;
|
||||
[Tooltip("默认旋转")] public Vector3 rotation;
|
||||
[Tooltip("默认形变")] public Vector3 scale;
|
||||
[Tooltip("是否可以放大缩小")] public bool canZoom;
|
||||
[Tooltip("放大缩小配置")] public Vector3 zoom;
|
||||
[Tooltip("是否可以平移")] public bool canPan;
|
||||
[Tooltip("平移配置")] public Rect pan;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Assets/PreviewableAsset.cs.meta
Normal file
3
Assets/Scripts/Model/Assets/PreviewableAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a000ba87cd97499eb23feecf39521ecb
|
||||
timeCreated: 1750736840
|
||||
8
Assets/Scripts/Model/Assets/PropAsset.cs
Normal file
8
Assets/Scripts/Model/Assets/PropAsset.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class PropAsset : PreviewableAsset
|
||||
{
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Assets/PropAsset.cs.meta
Normal file
3
Assets/Scripts/Model/Assets/PropAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea4d172189e248949431bb24b98369cb
|
||||
timeCreated: 1743824159
|
||||
113
Assets/Scripts/Model/Assets/ReelAsset.cs
Normal file
113
Assets/Scripts/Model/Assets/ReelAsset.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 线轴资产配置
|
||||
/// </summary>
|
||||
public class ReelAsset : PreviewableAsset
|
||||
{
|
||||
// "previewRotationEnabled": 1,
|
||||
// "previewRotation": {
|
||||
// "x": 20.0,
|
||||
// "y": -130.0,
|
||||
// "z": 190.0
|
||||
// },
|
||||
// "reelType": 3,
|
||||
// "reelSize": 11,
|
||||
// "minLineMeshScale": 0.93,
|
||||
// "maxLineMeshScale": 2.0,
|
||||
// "scaleX": 0,
|
||||
// "scaleY": 1,
|
||||
// "scaleZ": 1,
|
||||
// "rollHandleAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 5949981527590265242
|
||||
// },
|
||||
// "rollUkladchikAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 8960665928823962917
|
||||
// },
|
||||
// "rollShpulyaAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": -8671758223453786131
|
||||
// },
|
||||
// "frictionAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 0
|
||||
// },
|
||||
// "openAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": -2998254598457423134
|
||||
// },
|
||||
// "closeAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": -56605426968450186
|
||||
// },
|
||||
// "startEngineAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 0
|
||||
// },
|
||||
// "stopEngineAnimation": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 0
|
||||
// },
|
||||
// "handleAnimationLoopCycles": 6,
|
||||
// "ikLocatorFixEnabled": 0,
|
||||
// "ikLocatorFixRotation": {
|
||||
// "x": 0.0,
|
||||
// "y": 0.0,
|
||||
// "z": 0.0
|
||||
// },
|
||||
// "shiftRod": 0.0,
|
||||
// "materialWithSerial": {
|
||||
// "m_FileID": 0,
|
||||
// "m_PathID": 0
|
||||
// }
|
||||
|
||||
public enum Type
|
||||
{
|
||||
Normal = 0,
|
||||
Casting = 1
|
||||
}
|
||||
|
||||
public Type type;
|
||||
|
||||
/// <summary>
|
||||
/// 动画组件
|
||||
/// </summary>
|
||||
public Animator animator;
|
||||
|
||||
/// <summary>
|
||||
/// 根连接处
|
||||
/// </summary>
|
||||
public Transform rootConnector;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public Transform rootCompensator;
|
||||
|
||||
/// <summary>
|
||||
/// 线连接处
|
||||
/// </summary>
|
||||
public Transform lineConnector;
|
||||
|
||||
/// <summary>
|
||||
/// 线相交处
|
||||
/// </summary>
|
||||
public Transform lineIntersect;
|
||||
|
||||
public Transform lineIntersectHelper;
|
||||
|
||||
/// <summary>
|
||||
/// ik抓握挂点
|
||||
/// </summary>
|
||||
public Transform handle;
|
||||
|
||||
/// <summary>
|
||||
/// 手柄真实结束点
|
||||
/// </summary>
|
||||
public Transform handleEnd;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Assets/ReelAsset.cs.meta
Normal file
3
Assets/Scripts/Model/Assets/ReelAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8898b66b55404fd3be13b7dcdcfda463
|
||||
timeCreated: 1743785540
|
||||
61
Assets/Scripts/Model/Assets/RodAsset.cs
Normal file
61
Assets/Scripts/Model/Assets/RodAsset.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 鱼竿资产配置
|
||||
/// </summary>
|
||||
public class RodAsset : PreviewableAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 根节点
|
||||
/// </summary>
|
||||
public Transform root;
|
||||
|
||||
public Transform gripEnd;
|
||||
|
||||
/// <summary>
|
||||
/// 左手连接点
|
||||
/// </summary>
|
||||
public Transform LeftHandConnector;
|
||||
|
||||
/// <summary>
|
||||
/// 右手连接点
|
||||
/// </summary>
|
||||
public Transform RightHandConnector;
|
||||
|
||||
/// <summary>
|
||||
/// 线轴连接点
|
||||
/// </summary>
|
||||
public Transform ReelConnector;
|
||||
|
||||
/// <summary>
|
||||
/// 弯曲节点
|
||||
/// </summary>
|
||||
public Transform[] joints;
|
||||
|
||||
/// <summary>
|
||||
/// 圈挂点
|
||||
/// </summary>
|
||||
public Transform[] rings;
|
||||
|
||||
/// <summary>
|
||||
/// rings 画线
|
||||
/// </summary>
|
||||
public LineRenderer lineRenderer;
|
||||
|
||||
/// <summary>
|
||||
/// 鱼线连接点
|
||||
/// </summary>
|
||||
public Transform lineConnector;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (!lineConnector && joints.Length > 0)
|
||||
{
|
||||
lineConnector = joints[^1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Assets/RodAsset.cs.meta
Normal file
3
Assets/Scripts/Model/Assets/RodAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45b047324a3349b9aea42f50cbd1ba71
|
||||
timeCreated: 1743783252
|
||||
29
Assets/Scripts/Model/Assets/RodRingAsset.cs
Normal file
29
Assets/Scripts/Model/Assets/RodRingAsset.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 鱼竿导环资产配置
|
||||
/// </summary>
|
||||
public class RodRingAsset : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// 导环节点
|
||||
/// </summary>
|
||||
public RodRingNode[] rings;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class RodRingNode
|
||||
{
|
||||
/// <summary>
|
||||
/// 导环点位
|
||||
/// </summary>
|
||||
public Transform ring;
|
||||
|
||||
/// <summary>
|
||||
/// 线挂点
|
||||
/// </summary>
|
||||
public Transform point;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Assets/RodRingAsset.cs.meta
Normal file
3
Assets/Scripts/Model/Assets/RodRingAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cdfd33eb69534a1e87cd523df4bfb430
|
||||
timeCreated: 1743781816
|
||||
8
Assets/Scripts/Model/Assets/SpinnerLureAsset.cs
Normal file
8
Assets/Scripts/Model/Assets/SpinnerLureAsset.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class SpinnerLureAsset : PreviewableAsset
|
||||
{
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Assets/SpinnerLureAsset.cs.meta
Normal file
3
Assets/Scripts/Model/Assets/SpinnerLureAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed88dcaac7774ce79b04d90a3fa50533
|
||||
timeCreated: 1745487261
|
||||
3
Assets/Scripts/Model/Common.meta
Normal file
3
Assets/Scripts/Model/Common.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8426c4b03da403284afe458076b9c10
|
||||
timeCreated: 1742387508
|
||||
3
Assets/Scripts/Model/Common/Attrobites.meta
Normal file
3
Assets/Scripts/Model/Common/Attrobites.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cb50811095d496fad57afd7535d0f73
|
||||
timeCreated: 1748180763
|
||||
66
Assets/Scripts/Model/Common/Attrobites/AttributeHelper.cs
Normal file
66
Assets/Scripts/Model/Common/Attrobites/AttributeHelper.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public static class AttributeHelper
|
||||
{
|
||||
// 获取特定嵌套类中带有InputIconAttribute的常量字段
|
||||
public static Dictionary<string, List<FieldInfo>> GetNestedClassInputIconFields()
|
||||
{
|
||||
var result = new Dictionary<string, List<FieldInfo>>();
|
||||
|
||||
// 获取InputDef类型
|
||||
Type inputDefType = typeof(NBF.InputDef);
|
||||
|
||||
// 检查UI类
|
||||
Type uiType = inputDefType.GetNestedType("UI");
|
||||
if (uiType != null)
|
||||
{
|
||||
var uiFields = GetInputIconFieldsFromType(uiType);
|
||||
if (uiFields.Count > 0)
|
||||
{
|
||||
result.Add("UI", uiFields);
|
||||
}
|
||||
}
|
||||
|
||||
// 检查Player类
|
||||
Type playerType = inputDefType.GetNestedType("Player");
|
||||
if (playerType != null)
|
||||
{
|
||||
var playerFields = GetInputIconFieldsFromType(playerType);
|
||||
if (playerFields.Count > 0)
|
||||
{
|
||||
result.Add("Player", playerFields);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// 从特定类型获取带有InputIconAttribute的常量字段
|
||||
private static List<FieldInfo> GetInputIconFieldsFromType(Type type)
|
||||
{
|
||||
List<FieldInfo> result = new List<FieldInfo>();
|
||||
|
||||
// 只获取公共常量字段
|
||||
FieldInfo[] fields = type.GetFields(
|
||||
BindingFlags.Public |
|
||||
BindingFlags.Static |
|
||||
BindingFlags.FlattenHierarchy);
|
||||
|
||||
foreach (FieldInfo field in fields)
|
||||
{
|
||||
// 检查是否是常量且带有InputIconAttribute
|
||||
if (field.IsLiteral && !field.IsInitOnly &&
|
||||
Attribute.IsDefined(field, typeof(InputIconAttribute)))
|
||||
{
|
||||
result.Add(field);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa024ae7ea104f809ace6beff59c12d8
|
||||
timeCreated: 1748188551
|
||||
77
Assets/Scripts/Model/Common/Attrobites/Attributes.cs
Normal file
77
Assets/Scripts/Model/Common/Attrobites/Attributes.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public abstract class BaseAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class UIBindAttribute : BaseAttribute
|
||||
{
|
||||
public int Id;
|
||||
|
||||
public UIBindAttribute(int id)
|
||||
{
|
||||
this.Id = id;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class UIExtensionAutoBindAttribute : BaseAttribute
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InputIconAttribute : BaseAttribute
|
||||
{
|
||||
public string KeyBoardIcon;
|
||||
public string ControllerIcon;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="keyBoardIcon">键盘图标</param>
|
||||
/// <param name="controllerIcon">控制器图标</param>
|
||||
public InputIconAttribute(string keyBoardIcon, string controllerIcon)
|
||||
{
|
||||
KeyBoardIcon = keyBoardIcon;
|
||||
ControllerIcon = controllerIcon;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class, AllowMultiple = true)]
|
||||
public class TitleAttribute : BaseAttribute
|
||||
{
|
||||
public string Title;
|
||||
|
||||
public TitleAttribute(string title)
|
||||
{
|
||||
Title = title;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class, AllowMultiple = true)]
|
||||
public class DescriptionAttribute : BaseAttribute
|
||||
{
|
||||
public string Description;
|
||||
|
||||
public DescriptionAttribute(string description)
|
||||
{
|
||||
Description = description;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class, AllowMultiple = true)]
|
||||
public class SortAttribute : BaseAttribute
|
||||
{
|
||||
public int Sort;
|
||||
|
||||
public SortAttribute(int sort)
|
||||
{
|
||||
Sort = sort;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 647174a4726c4c4c92193aa7dcd3ddad
|
||||
timeCreated: 1748509835
|
||||
77
Assets/Scripts/Model/Common/BaseCamera.cs
Normal file
77
Assets/Scripts/Model/Common/BaseCamera.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using FairyGUI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class BaseCamera : MonoBehaviour
|
||||
{
|
||||
public static Camera Main { get; private set; }
|
||||
|
||||
public static UniversalAdditionalCameraData MainCameraData { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Init();
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
Main = GetComponent<Camera>();
|
||||
MainCameraData = Main.GetUniversalAdditionalCameraData();
|
||||
}
|
||||
|
||||
|
||||
private static void FixUICamera()
|
||||
{
|
||||
if (StageCamera.main == null) return;
|
||||
var stageCameraData = StageCamera.main.GetUniversalAdditionalCameraData();
|
||||
if (stageCameraData != null)
|
||||
{
|
||||
if (MainCameraData.cameraStack.Contains(StageCamera.main)) // 防止重复添加
|
||||
{
|
||||
RemoveStack(StageCamera.main);
|
||||
}
|
||||
|
||||
AddStack(StageCamera.main);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetOverlay(Camera camera, UniversalAdditionalCameraData stageCameraData = null)
|
||||
{
|
||||
if (stageCameraData == null)
|
||||
{
|
||||
stageCameraData = camera.GetUniversalAdditionalCameraData();
|
||||
}
|
||||
|
||||
if (stageCameraData != null)
|
||||
{
|
||||
stageCameraData.renderType = CameraRenderType.Overlay;
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddStack(Camera overlayCamera)
|
||||
{
|
||||
if (!MainCameraData.cameraStack.Contains(overlayCamera)) // 防止重复添加
|
||||
{
|
||||
SetOverlay(overlayCamera);
|
||||
MainCameraData.cameraStack.Add(overlayCamera);
|
||||
}
|
||||
|
||||
if (overlayCamera != StageCamera.main)
|
||||
{
|
||||
FixUICamera();
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveStack(Camera overlayCamera)
|
||||
{
|
||||
if (MainCameraData.cameraStack.Contains(overlayCamera))
|
||||
{
|
||||
MainCameraData.cameraStack.Remove(overlayCamera);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Common/BaseCamera.cs.meta
Normal file
3
Assets/Scripts/Model/Common/BaseCamera.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c40f26e5da0a454b93cd5d1e94157699
|
||||
timeCreated: 1742635242
|
||||
3
Assets/Scripts/Model/Common/Enum.meta
Normal file
3
Assets/Scripts/Model/Common/Enum.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef884391e7a4450a9cfc633e1c7a8785
|
||||
timeCreated: 1742999159
|
||||
75
Assets/Scripts/Model/Common/Enum/FishSpecies.cs
Normal file
75
Assets/Scripts/Model/Common/Enum/FishSpecies.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
namespace NBF
|
||||
{
|
||||
public enum FishSpecies
|
||||
{
|
||||
BlackBullhead = 0,
|
||||
Perch = 1,
|
||||
SalmonSockeye = 2,
|
||||
TroutRainbow = 3,
|
||||
BassSmallmouth = 4,
|
||||
PerchYellow = 5,
|
||||
Asp = 6,
|
||||
CommonBarbel = 7,
|
||||
CommonBream = 8,
|
||||
BreamSilver = 9,
|
||||
Burbot = 10,
|
||||
CarpCommon = 11,
|
||||
CarpMirror = 12,
|
||||
CarpSezan = 13,
|
||||
CarpGrass = 14,
|
||||
CarpSilver = 15,
|
||||
CarpCrucian = 16,
|
||||
CarpPrussian = 17,
|
||||
CatfishChannel = 18,
|
||||
CatfishFlathead = 19,
|
||||
CatfishRedtail = 20,
|
||||
CatfishWels = 21,
|
||||
Chub = 22,
|
||||
EuropeanGrayling = 23,
|
||||
Ide = 24,
|
||||
PickerelChain = 25,
|
||||
PickerelGrass = 26,
|
||||
PickerelRedfin = 27,
|
||||
PikeAmur = 28,
|
||||
PikeNorthern = 29,
|
||||
PikeSoutherm = 30,
|
||||
PikeMuskellunge = 31,
|
||||
Roach = 32,
|
||||
Tench = 33,
|
||||
Zander = 34,
|
||||
BassLargemouth = 35,
|
||||
Bluegill = 36,
|
||||
Pumpkinseed = 37,
|
||||
AtlanticSalmon = 38,
|
||||
CommonBleak = 39,
|
||||
Huchen = 40,
|
||||
BrookTrout = 41,
|
||||
BrownTrout = 42,
|
||||
EuropeanBass = 43,
|
||||
AtlanticCod = 44,
|
||||
CrocodileNeedlefish = 45,
|
||||
EuropeanEel = 46,
|
||||
EuropeanFlounder = 47,
|
||||
Garfish = 48,
|
||||
EuropeanSeaSturgeon = 49,
|
||||
SeaTrout = 50,
|
||||
Beluga = 51,
|
||||
BaikalBlackGrayling = 52,
|
||||
ChumSalmon = 53,
|
||||
CohoSalmon = 54,
|
||||
PinkSalmon = 55,
|
||||
BarracudaGreat = 56,
|
||||
BarracudaYellowtail = 57,
|
||||
GrouperGiant = 58,
|
||||
GrouperMalabar = 59,
|
||||
LionfishRed = 60,
|
||||
MahiMahi = 61,
|
||||
SharkBlacktipReef = 62,
|
||||
SharkTiger = 63,
|
||||
SnapperGrey = 64,
|
||||
TreadfishIndian = 65,
|
||||
TrevallyGiant = 66,
|
||||
TunaYellowfin = 67,
|
||||
ZombieBass = 68
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Common/Enum/FishSpecies.cs.meta
Normal file
3
Assets/Scripts/Model/Common/Enum/FishSpecies.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da1c9ef59c57429083f79d8c2a1bec86
|
||||
timeCreated: 1742999162
|
||||
3
Assets/Scripts/Model/Common/Input.meta
Normal file
3
Assets/Scripts/Model/Common/Input.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1977fd60c4b24f33bc4143aaed9fba8a
|
||||
timeCreated: 1755792367
|
||||
10
Assets/Scripts/Model/Common/Input/InteractiveObject.cs
Normal file
10
Assets/Scripts/Model/Common/Input/InteractiveObject.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class InteractiveObject : MonoBehaviour
|
||||
{
|
||||
[Header("交互类型")] public UIDef.InteractiveType Type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa29ad8321da4a29a6fb475e9e97f87e
|
||||
timeCreated: 1747577976
|
||||
2773
Assets/Scripts/Model/Common/Input/PlayerInputControl.cs
Normal file
2773
Assets/Scripts/Model/Common/Input/PlayerInputControl.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cdaa795bad2ccc34faab0c9036785b02
|
||||
249
Assets/Scripts/Model/Common/Outline.cs
Normal file
249
Assets/Scripts/Model/Common/Outline.cs
Normal file
@@ -0,0 +1,249 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
public class Outline : MonoBehaviour
|
||||
{
|
||||
public enum Mode
|
||||
{
|
||||
OutlineAll = 0,
|
||||
OutlineVisible = 1,
|
||||
OutlineHidden = 2,
|
||||
OutlineAndSilhouette = 3,
|
||||
SilhouetteOnly = 4
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
private class ListVector3
|
||||
{
|
||||
public List<Vector3> data;
|
||||
}
|
||||
|
||||
private static HashSet<Mesh> registeredMeshes = new HashSet<Mesh>();
|
||||
|
||||
[SerializeField] private Mode outlineMode;
|
||||
|
||||
[SerializeField] private Color outlineColor = Color.white;
|
||||
|
||||
[SerializeField] [Range(0f, 10f)] private float outlineWidth = 2f;
|
||||
|
||||
[Header("Optional")]
|
||||
[SerializeField]
|
||||
[Tooltip(
|
||||
"Precompute enabled: Per-vertex calculations are performed in the editor and serialized with the object. Precompute disabled: Per-vertex calculations are performed at runtime in Awake(). This may cause a pause for large meshes.")]
|
||||
private bool precomputeOutline;
|
||||
|
||||
[SerializeField] [HideInInspector] private List<Mesh> bakeKeys = new List<Mesh>();
|
||||
|
||||
[SerializeField] [HideInInspector] private List<ListVector3> bakeValues = new List<ListVector3>();
|
||||
|
||||
private Renderer[] renderers;
|
||||
|
||||
private Material outlineMaskMaterial;
|
||||
|
||||
private Material outlineFillMaterial;
|
||||
|
||||
private bool needsUpdate;
|
||||
|
||||
public Mode OutlineMode
|
||||
{
|
||||
get { return outlineMode; }
|
||||
set
|
||||
{
|
||||
outlineMode = value;
|
||||
needsUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
public Color OutlineColor
|
||||
{
|
||||
get { return outlineColor; }
|
||||
set
|
||||
{
|
||||
outlineColor = value;
|
||||
needsUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
public float OutlineWidth
|
||||
{
|
||||
get { return outlineWidth; }
|
||||
set
|
||||
{
|
||||
outlineWidth = value;
|
||||
needsUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
renderers = GetComponentsInChildren<Renderer>();
|
||||
outlineMaskMaterial = Instantiate(Resources.Load<Material>("Materials/OutlineMask"));
|
||||
outlineFillMaterial = Instantiate(Resources.Load<Material>("Materials/OutlineFill"));
|
||||
outlineMaskMaterial.name = "OutlineMask (Instance)";
|
||||
outlineFillMaterial.name = "OutlineFill (Instance)";
|
||||
LoadSmoothNormals();
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
Renderer[] array = renderers;
|
||||
foreach (Renderer obj in array)
|
||||
{
|
||||
List<Material> list = Enumerable.ToList(obj.sharedMaterials);
|
||||
list.Add(outlineMaskMaterial);
|
||||
list.Add(outlineFillMaterial);
|
||||
obj.materials = list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
needsUpdate = true;
|
||||
if ((!precomputeOutline && bakeKeys.Count != 0) || bakeKeys.Count != bakeValues.Count)
|
||||
{
|
||||
bakeKeys.Clear();
|
||||
bakeValues.Clear();
|
||||
}
|
||||
|
||||
if (precomputeOutline && bakeKeys.Count == 0)
|
||||
{
|
||||
Bake();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (needsUpdate)
|
||||
{
|
||||
needsUpdate = false;
|
||||
UpdateMaterialProperties();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Renderer[] array = renderers;
|
||||
foreach (Renderer obj in array)
|
||||
{
|
||||
List<Material> list = Enumerable.ToList(obj.sharedMaterials);
|
||||
list.Remove(outlineMaskMaterial);
|
||||
list.Remove(outlineFillMaterial);
|
||||
obj.materials = list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Destroy(outlineMaskMaterial);
|
||||
Destroy(outlineFillMaterial);
|
||||
}
|
||||
|
||||
private void Bake()
|
||||
{
|
||||
HashSet<Mesh> hashSet = new HashSet<Mesh>();
|
||||
MeshFilter[] componentsInChildren = GetComponentsInChildren<MeshFilter>();
|
||||
foreach (MeshFilter meshFilter in componentsInChildren)
|
||||
{
|
||||
if (hashSet.Add(meshFilter.sharedMesh))
|
||||
{
|
||||
List<Vector3> data = SmoothNormals(meshFilter.sharedMesh);
|
||||
bakeKeys.Add(meshFilter.sharedMesh);
|
||||
bakeValues.Add(new ListVector3
|
||||
{
|
||||
data = data
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadSmoothNormals()
|
||||
{
|
||||
MeshFilter[] componentsInChildren = GetComponentsInChildren<MeshFilter>();
|
||||
foreach (MeshFilter meshFilter in componentsInChildren)
|
||||
{
|
||||
if (registeredMeshes.Add(meshFilter.sharedMesh))
|
||||
{
|
||||
int num = bakeKeys.IndexOf(meshFilter.sharedMesh);
|
||||
List<Vector3> uvs = ((num >= 0) ? bakeValues[num].data : SmoothNormals(meshFilter.sharedMesh));
|
||||
meshFilter.sharedMesh.SetUVs(3, uvs);
|
||||
}
|
||||
}
|
||||
|
||||
SkinnedMeshRenderer[] componentsInChildren2 = GetComponentsInChildren<SkinnedMeshRenderer>();
|
||||
foreach (SkinnedMeshRenderer skinnedMeshRenderer in componentsInChildren2)
|
||||
{
|
||||
if (registeredMeshes.Add(skinnedMeshRenderer.sharedMesh))
|
||||
{
|
||||
skinnedMeshRenderer.sharedMesh.uv4 = new Vector2[skinnedMeshRenderer.sharedMesh.vertexCount];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Vector3> SmoothNormals(Mesh mesh)
|
||||
{
|
||||
IEnumerable<IGrouping<Vector3, KeyValuePair<Vector3, int>>> enumerable =
|
||||
Enumerable.GroupBy(
|
||||
Enumerable.Select(mesh.vertices,
|
||||
(Vector3 vertex, int index) => new KeyValuePair<Vector3, int>(vertex, index)),
|
||||
(KeyValuePair<Vector3, int> pair) => pair.Key);
|
||||
List<Vector3> list = new List<Vector3>(mesh.normals);
|
||||
foreach (IGrouping<Vector3, KeyValuePair<Vector3, int>> item in enumerable)
|
||||
{
|
||||
if (Enumerable.Count(item) == 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector3 zero = Vector3.zero;
|
||||
foreach (KeyValuePair<Vector3, int> item2 in item)
|
||||
{
|
||||
zero += mesh.normals[item2.Value];
|
||||
}
|
||||
|
||||
zero.Normalize();
|
||||
foreach (KeyValuePair<Vector3, int> item3 in item)
|
||||
{
|
||||
list[item3.Value] = zero;
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private void UpdateMaterialProperties()
|
||||
{
|
||||
outlineFillMaterial.SetColor("_OutlineColor", outlineColor);
|
||||
switch (outlineMode)
|
||||
{
|
||||
case Mode.OutlineAll:
|
||||
outlineMaskMaterial.SetFloat("_ZTest", 8f);
|
||||
outlineFillMaterial.SetFloat("_ZTest", 8f);
|
||||
outlineFillMaterial.SetFloat("_OutlineWidth", outlineWidth);
|
||||
break;
|
||||
case Mode.OutlineVisible:
|
||||
outlineMaskMaterial.SetFloat("_ZTest", 8f);
|
||||
outlineFillMaterial.SetFloat("_ZTest", 4f);
|
||||
outlineFillMaterial.SetFloat("_OutlineWidth", outlineWidth);
|
||||
break;
|
||||
case Mode.OutlineHidden:
|
||||
outlineMaskMaterial.SetFloat("_ZTest", 8f);
|
||||
outlineFillMaterial.SetFloat("_ZTest", 5f);
|
||||
outlineFillMaterial.SetFloat("_OutlineWidth", outlineWidth);
|
||||
break;
|
||||
case Mode.OutlineAndSilhouette:
|
||||
outlineMaskMaterial.SetFloat("_ZTest", 4f);
|
||||
outlineFillMaterial.SetFloat("_ZTest", 8f);
|
||||
outlineFillMaterial.SetFloat("_OutlineWidth", outlineWidth);
|
||||
break;
|
||||
case Mode.SilhouetteOnly:
|
||||
outlineMaskMaterial.SetFloat("_ZTest", 4f);
|
||||
outlineFillMaterial.SetFloat("_ZTest", 5f);
|
||||
outlineFillMaterial.SetFloat("_OutlineWidth", 0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Common/Outline.cs.meta
Normal file
3
Assets/Scripts/Model/Common/Outline.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 944328972a42400fa3fa1289ba2a1e2e
|
||||
timeCreated: 1742387511
|
||||
30
Assets/Scripts/Model/Common/PermanentCommon.cs
Normal file
30
Assets/Scripts/Model/Common/PermanentCommon.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using NBC;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary>
|
||||
/// 常驻公共脚本
|
||||
/// </summary>
|
||||
public class PermanentCommon
|
||||
{
|
||||
private static bool _init;
|
||||
private static PermanentCommon _inst;
|
||||
|
||||
public static PermanentCommon Inst
|
||||
{
|
||||
get { return _inst ??= new PermanentCommon(); }
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
if (_init) return;
|
||||
_init = true;
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
{
|
||||
_init = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Common/PermanentCommon.cs.meta
Normal file
3
Assets/Scripts/Model/Common/PermanentCommon.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3816467cfd1648e685a33ebfd1d9fb7d
|
||||
timeCreated: 1748184924
|
||||
3
Assets/Scripts/Model/Common/Services.meta
Normal file
3
Assets/Scripts/Model/Common/Services.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 011d59a9e9454122bc76461e942de184
|
||||
timeCreated: 1748489400
|
||||
3
Assets/Scripts/Model/Common/Services/Input.meta
Normal file
3
Assets/Scripts/Model/Common/Services/Input.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d846463d130b4191a5a4a9d2e2dfe45b
|
||||
timeCreated: 1748180579
|
||||
@@ -0,0 +1,46 @@
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public static class InputCursorExtension
|
||||
{
|
||||
public static void InputInit()
|
||||
{
|
||||
// UI.Inst.On(UIEvents.UIShow, UIShow, null, 1);
|
||||
// UI.Inst.On(UIEvents.UIHide, UIHide, null, 1);
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
private static void UIShow(EventArgs ev)
|
||||
{
|
||||
CheckUICursor();
|
||||
}
|
||||
|
||||
private static void UIHide(EventArgs ev)
|
||||
{
|
||||
CheckUICursor();
|
||||
}
|
||||
|
||||
|
||||
private static void CheckUICursor()
|
||||
{
|
||||
var uis = App.UI.GetAllUI();
|
||||
bool showCursor = false;
|
||||
foreach (var ui in uis)
|
||||
{
|
||||
if (!ui.IsShowing) continue;
|
||||
if (ui.IsShowCursor)
|
||||
{
|
||||
showCursor = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Log.Error($"showCursor={showCursor}");
|
||||
InputManager.IsUIStopInput = showCursor;
|
||||
InputManager.SetMouseCursor(showCursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0644b8eb12e44351ab75b467f90d4c32
|
||||
timeCreated: 1748185434
|
||||
213
Assets/Scripts/Model/Common/Services/Input/InputManager.cs
Normal file
213
Assets/Scripts/Model/Common/Services/Input/InputManager.cs
Normal file
@@ -0,0 +1,213 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using NBC;
|
||||
// using Rewired;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public enum ControllerType
|
||||
{
|
||||
KeyboardMouse = 0,
|
||||
GamePad = 1
|
||||
}
|
||||
|
||||
public class InputManager : MonoService<InputManager>
|
||||
{
|
||||
public static bool IsOp1;
|
||||
public static bool IsOp2;
|
||||
|
||||
public static event Action<bool> OnOp1Action;
|
||||
public static event Action<bool> OnOp2Action;
|
||||
|
||||
/// <summary>
|
||||
/// 执行输入事件
|
||||
/// </summary>
|
||||
public static event Action<string> OnUIPerformed;
|
||||
|
||||
/// <summary>
|
||||
/// 执行输入事件完毕
|
||||
/// </summary>
|
||||
public static event Action<string> OnUICanceled;
|
||||
|
||||
/// <summary>
|
||||
/// 执行输入事件
|
||||
/// </summary>
|
||||
public static event Action<string> OnPlayerPerformed;
|
||||
|
||||
/// <summary>
|
||||
/// 执行输入事件完毕
|
||||
/// </summary>
|
||||
public static event Action<string> OnPlayerCanceled;
|
||||
|
||||
/// <summary>
|
||||
/// 触发交互游戏对象
|
||||
/// </summary>
|
||||
public static event Action<InteractiveObject> OnInteractiveObjectAction;
|
||||
|
||||
public static PlayerInputControl PlayerInputControl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 手柄输入
|
||||
/// </summary>
|
||||
public static bool IsControllerInput;
|
||||
|
||||
/// <summary>
|
||||
/// ui阻止游戏输入
|
||||
/// </summary>
|
||||
public static bool IsUIStopInput;
|
||||
|
||||
public static ControllerType ControllerType = ControllerType.KeyboardMouse;
|
||||
|
||||
protected override void OnAwake()
|
||||
{
|
||||
InputCursorExtension.InputInit();
|
||||
DontDestroyOnLoad(gameObject);
|
||||
PlayerInputControl = new PlayerInputControl();
|
||||
PlayerInputControl.Enable();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
AddEvent();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
RemoveEvent();
|
||||
InputCursorExtension.Dispose();
|
||||
}
|
||||
|
||||
|
||||
public static void SetMouseCursor(bool val)
|
||||
{
|
||||
if (val)
|
||||
{
|
||||
if (ControllerType == ControllerType.KeyboardMouse)
|
||||
{
|
||||
Cursor.visible = true;
|
||||
}
|
||||
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
else if (ControllerType == ControllerType.KeyboardMouse)
|
||||
{
|
||||
Cursor.visible = false;
|
||||
}
|
||||
|
||||
Cursor.visible = val;
|
||||
if (!val)
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Confined;
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector2 GetMovementInput()
|
||||
{
|
||||
if (IsUIStopInput) return Vector2.zero;
|
||||
return PlayerInputControl.Player.Move?.ReadValue<Vector2>() ?? Vector2.zero;
|
||||
}
|
||||
|
||||
public static Vector2 GetLookInput()
|
||||
{
|
||||
if (IsUIStopInput) return Vector2.zero;
|
||||
return PlayerInputControl.Player.Look?.ReadValue<Vector2>() ?? Vector2.zero;
|
||||
}
|
||||
|
||||
|
||||
private void AddEvent()
|
||||
{
|
||||
foreach (var actionMap in PlayerInputControl.asset.actionMaps)
|
||||
{
|
||||
actionMap.Enable();
|
||||
if (actionMap.name == "UI")
|
||||
{
|
||||
foreach (var action in actionMap.actions)
|
||||
{
|
||||
if (action.type == InputActionType.Button)
|
||||
{
|
||||
action.performed += OnUIButtonPerformed;
|
||||
action.canceled += OnUIButtonCanceled;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (actionMap.name == "Player")
|
||||
{
|
||||
foreach (var action in actionMap.actions)
|
||||
{
|
||||
if (action.type == InputActionType.Button)
|
||||
{
|
||||
action.performed += OnPlayerButtonPerformed;
|
||||
action.canceled += OnPlayerButtonCanceled;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveEvent()
|
||||
{
|
||||
OnUIPerformed = null;
|
||||
OnUICanceled = null;
|
||||
OnPlayerPerformed = null;
|
||||
OnPlayerCanceled = null;
|
||||
}
|
||||
|
||||
private void OnUIButtonPerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
OnUIPerformed?.Invoke(context.action.name);
|
||||
}
|
||||
|
||||
private void OnUIButtonCanceled(InputAction.CallbackContext context)
|
||||
{
|
||||
OnUICanceled?.Invoke(context.action.name);
|
||||
}
|
||||
|
||||
private void OnPlayerButtonPerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
if (IsUIStopInput) return;
|
||||
var actionName = context.action.name;
|
||||
if (actionName == "Op1")
|
||||
{
|
||||
OnOp1Action?.Invoke(true);
|
||||
}
|
||||
else if (actionName == "Op2")
|
||||
{
|
||||
OnOp2Action?.Invoke(true);
|
||||
}
|
||||
|
||||
OnPlayerPerformed?.Invoke(actionName);
|
||||
}
|
||||
|
||||
private void OnPlayerButtonCanceled(InputAction.CallbackContext context)
|
||||
{
|
||||
if (IsUIStopInput) return;
|
||||
var actionName = context.action.name;
|
||||
if (actionName == "Op1")
|
||||
{
|
||||
OnOp1Action?.Invoke(false);
|
||||
}
|
||||
else if (actionName == "Op2")
|
||||
{
|
||||
OnOp2Action?.Invoke(false);
|
||||
}
|
||||
|
||||
OnPlayerCanceled?.Invoke(actionName);
|
||||
}
|
||||
|
||||
|
||||
public void OnInteractiveObject(InteractiveObject interactiveObject)
|
||||
{
|
||||
Debug.LogError($"OnInteractiveObject {interactiveObject != null}");
|
||||
OnInteractiveObjectAction?.Invoke(interactiveObject);
|
||||
}
|
||||
|
||||
public void SendUIInput(string actionName)
|
||||
{
|
||||
OnUIPerformed?.Invoke(actionName);
|
||||
OnUICanceled?.Invoke(actionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fecc50928be248b896f6ee0a17e7b76d
|
||||
timeCreated: 1746892722
|
||||
24
Assets/Scripts/Model/Common/Services/MonoService.cs
Normal file
24
Assets/Scripts/Model/Common/Services/MonoService.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using NBC;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public abstract class MonoService : MonoBehaviour
|
||||
{
|
||||
}
|
||||
|
||||
public abstract class MonoService<T> : MonoService where T : MonoService
|
||||
{
|
||||
public static T Instance { get; private set; }
|
||||
|
||||
protected void Awake()
|
||||
{
|
||||
Instance = this as T;
|
||||
OnAwake();
|
||||
}
|
||||
|
||||
protected virtual void OnAwake()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Model/Common/Services/MonoService.cs.meta
Normal file
3
Assets/Scripts/Model/Common/Services/MonoService.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62c58708f36041db9bb11a7e4d16c62c
|
||||
timeCreated: 1748491579
|
||||
3
Assets/Scripts/Model/Common/Services/Settings.meta
Normal file
3
Assets/Scripts/Model/Common/Services/Settings.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6111c0ab89e74c9fada884e4e4051549
|
||||
timeCreated: 1748489421
|
||||
3
Assets/Scripts/Model/Common/Services/Settings/Base.meta
Normal file
3
Assets/Scripts/Model/Common/Services/Settings/Base.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c12ca701ad9f433d9e6e7eaf04f507d0
|
||||
timeCreated: 1748570535
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public abstract class ControllerOption : OptionBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75e11d5298cd48718d39a3e2af82472f
|
||||
timeCreated: 1749634909
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public abstract class GamepadOption : InputOption
|
||||
{
|
||||
protected override bool IsBindingContains(InputBinding binding)
|
||||
{
|
||||
var path = binding.path;
|
||||
if (path.Contains("<Gamepad>"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49041e6a08b744038368d7010acf61ea
|
||||
timeCreated: 1750408186
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using NBF.Setting;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public interface ISettings
|
||||
{
|
||||
List<OptionBase> GetOptionsByTab(string group);
|
||||
IEnumerable<string> GetAllTabs();
|
||||
T GetSettingOption<T>() where T : OptionBase;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2cb28b8c7664cc28fe0b0a0a4516704
|
||||
timeCreated: 1748678126
|
||||
@@ -0,0 +1,96 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public abstract class InputOption : OptionBase
|
||||
{
|
||||
private int _bindingIndex = 0;
|
||||
public abstract InputAction InputAction { get; }
|
||||
|
||||
public int BindingIndex => _bindingIndex;
|
||||
|
||||
protected override int DefaultValue => 0;
|
||||
|
||||
/// <summary>
|
||||
/// 保存的值
|
||||
/// </summary>
|
||||
protected string InputSaveValue;
|
||||
|
||||
public override bool HaveNotApple()
|
||||
{
|
||||
return !InputAction.SaveBindingOverridesAsJson().Equals(InputSaveValue);
|
||||
}
|
||||
|
||||
public override void Apply()
|
||||
{
|
||||
// 保存绑定
|
||||
InputSaveValue = InputAction.SaveBindingOverridesAsJson();
|
||||
PlayerPrefs.SetString(SaveKey, InputSaveValue);
|
||||
OnApply();
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
for (int i = 0; i < InputAction.bindings.Count; i++)
|
||||
{
|
||||
var binding = InputAction.bindings[i];
|
||||
if (IsBindingContains(binding))
|
||||
{
|
||||
_bindingIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var value = PlayerPrefs.GetString(SaveKey, string.Empty);
|
||||
InputSaveValue = value;
|
||||
if (!string.IsNullOrEmpty(InputSaveValue))
|
||||
{
|
||||
InputAction.LoadBindingOverridesFromJson(InputSaveValue);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
if (InputAction.bindings[BindingIndex].isComposite)
|
||||
{
|
||||
// It's a composite. Remove overrides from part bindings.
|
||||
for (var i = BindingIndex + 1;
|
||||
i < InputAction.bindings.Count && InputAction.bindings[i].isPartOfComposite;
|
||||
++i)
|
||||
InputAction.RemoveBindingOverride(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
InputAction.RemoveBindingOverride(BindingIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Cancel()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(InputSaveValue))
|
||||
{
|
||||
InputAction.LoadBindingOverridesFromJson(InputSaveValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetDisplayString()
|
||||
{
|
||||
if (InputAction != null)
|
||||
{
|
||||
return InputAction.GetBindingDisplayString(BindingIndex);
|
||||
}
|
||||
|
||||
return base.GetDisplayString();
|
||||
}
|
||||
|
||||
protected virtual bool IsBindingContains(InputBinding binding)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0df4bee5d9b54ada8be3757d7fe02e30
|
||||
timeCreated: 1749634814
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public abstract class KeyBoardOption : InputOption
|
||||
{
|
||||
protected override bool IsBindingContains(InputBinding binding)
|
||||
{
|
||||
var path = binding.path;
|
||||
if (path.Contains("<Keyboard>") || path.Contains("<Mouse>"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 509d2fb0106b42b79854cca29707207d
|
||||
timeCreated: 1749634771
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public interface IMultiOption : IOptionBase
|
||||
{
|
||||
List<string> GetOptionNames();
|
||||
}
|
||||
|
||||
public abstract class MultiOption<T> : OptionBase, IMultiOption
|
||||
{
|
||||
protected OptionTable<T> OptionTable = new OptionTable<T>();
|
||||
|
||||
|
||||
protected void AddOption(string name, T value)
|
||||
{
|
||||
OptionTable.Add(name, value);
|
||||
}
|
||||
|
||||
public List<string> GetOptionNames() => OptionTable.GetNames();
|
||||
|
||||
|
||||
protected void SelectOption(T value, int defaultIndex = 0)
|
||||
{
|
||||
SetValue(TryGetIndex(value, out var index) ? index : defaultIndex);
|
||||
}
|
||||
|
||||
protected void SelectOption(Predicate<T> predicate, int defaultIndex = 0)
|
||||
{
|
||||
SetValue(TryGetIndex(predicate, out var index) ? index : defaultIndex);
|
||||
}
|
||||
|
||||
protected bool TryGetIndex(T option, out int index)
|
||||
{
|
||||
return TryGetIndex(entry => entry.Equals(option), out index);
|
||||
}
|
||||
|
||||
protected bool TryGetIndex(Predicate<T> predicate, out int index)
|
||||
{
|
||||
index = -1;
|
||||
|
||||
var entries = OptionTable.GetValues();
|
||||
|
||||
for (var i = 0; i < entries.Count; i++)
|
||||
{
|
||||
if (!predicate(entries[i])) continue;
|
||||
index = i;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public T GetSelectedOption() => OptionTable.GetValue(Value);
|
||||
|
||||
public override string GetDisplayString()
|
||||
{
|
||||
return OptionTable.GetName(Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b25650e359243468131db1f9b951ae7
|
||||
timeCreated: 1748571045
|
||||
115
Assets/Scripts/Model/Common/Services/Settings/Base/OptionBase.cs
Normal file
115
Assets/Scripts/Model/Common/Services/Settings/Base/OptionBase.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public interface IOptionBase
|
||||
{
|
||||
string Name { get; }
|
||||
void Initialize(ISettings root);
|
||||
void Apply();
|
||||
int GetValue();
|
||||
void SetValue(int index);
|
||||
bool HaveNotApple();
|
||||
ISettings Root { get; }
|
||||
string GetDisplayString();
|
||||
}
|
||||
|
||||
public abstract class OptionBase : IOptionBase
|
||||
{
|
||||
protected string SaveKey => $"Setting_{Group}_{Name}";
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 所在组
|
||||
/// </summary>
|
||||
public abstract string Group { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 所在分切页
|
||||
/// </summary>
|
||||
public abstract string Tab { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认值
|
||||
/// </summary>
|
||||
protected abstract int DefaultValue { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前的值
|
||||
/// </summary>
|
||||
protected int Value;
|
||||
|
||||
/// <summary>
|
||||
/// 保存的值
|
||||
/// </summary>
|
||||
protected int SaveValue;
|
||||
|
||||
public virtual bool HaveNotApple()
|
||||
{
|
||||
return !Value.Equals(SaveValue);
|
||||
}
|
||||
|
||||
public ISettings Root { get; private set; }
|
||||
|
||||
|
||||
public void Initialize(ISettings root)
|
||||
{
|
||||
Root = root;
|
||||
Load();
|
||||
OnInitialize();
|
||||
Apply();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载用户的设置
|
||||
/// </summary>
|
||||
public virtual void Load()
|
||||
{
|
||||
var value = PlayerPrefs.GetInt(SaveKey, DefaultValue);
|
||||
Value = value;
|
||||
SaveValue = value;
|
||||
}
|
||||
|
||||
public virtual void Apply()
|
||||
{
|
||||
PlayerPrefs.SetInt(SaveKey, Value);
|
||||
SaveValue = Value;
|
||||
OnApply();
|
||||
}
|
||||
|
||||
public virtual void Reset()
|
||||
{
|
||||
Value = DefaultValue;
|
||||
}
|
||||
|
||||
public virtual void Cancel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public virtual string GetDisplayString()
|
||||
{
|
||||
return GetValue().ToString();
|
||||
}
|
||||
|
||||
public virtual int GetValue()
|
||||
{
|
||||
return Value;
|
||||
}
|
||||
|
||||
public virtual void SetValue(int value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
|
||||
protected virtual void OnInitialize()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
protected abstract void OnApply();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd2d6f346b1145debf370bc3ac71bd7e
|
||||
timeCreated: 1748570612
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public class OptionTable<T>
|
||||
{
|
||||
public struct OptionEntry
|
||||
{
|
||||
public string Name;
|
||||
public T Value;
|
||||
|
||||
public OptionEntry(string name, T value)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
List<OptionEntry> entries = new List<OptionEntry>();
|
||||
|
||||
public void Add(string name, T value)
|
||||
{
|
||||
entries.Add(new OptionEntry(name, value));
|
||||
}
|
||||
|
||||
public List<string> GetNames() => entries.Select(x => x.Name).ToList();
|
||||
public List<T> GetValues() => entries.Select(x => x.Value).ToList();
|
||||
|
||||
public T GetValue(int index)
|
||||
{
|
||||
if (entries == null) return default;
|
||||
if (index < 0 || index >= entries.Count) return default;
|
||||
return entries[index].Value;
|
||||
}
|
||||
|
||||
public string GetName(int index)
|
||||
{
|
||||
if (entries == null) return string.Empty;
|
||||
if (index < 0 || index >= entries.Count) return string.Empty;
|
||||
return entries[index].Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7241b5524db446eb4f73ae3a8d7b0ec
|
||||
timeCreated: 1748571519
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
/// <summary>
|
||||
/// 范围设置
|
||||
/// </summary>
|
||||
public abstract class RangeOption : OptionBase
|
||||
{
|
||||
public abstract int MinValue { get; }
|
||||
public abstract int MaxValue { get; }
|
||||
|
||||
public virtual int ShowRate => 0;
|
||||
|
||||
public override void SetValue(int value)
|
||||
{
|
||||
if (value > MaxValue) value = MaxValue;
|
||||
else if (value < MinValue) value = MinValue;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public override string GetDisplayString()
|
||||
{
|
||||
if (ShowRate > 0)
|
||||
{
|
||||
return Math.Round(GetValue() / (ShowRate * 1f), 1).ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
return base.GetDisplayString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3531567c76fc48d5939644966fe22057
|
||||
timeCreated: 1748572844
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public abstract class ToggleOption : MultiOption<bool>
|
||||
{
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
AddOption("Off", false);
|
||||
AddOption("On", true);
|
||||
|
||||
SelectOption(DefaultValue == 1);
|
||||
}
|
||||
|
||||
public bool IsEnabled() => GetSelectedOption();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbcf52430d8b483497f040fe7cbcfa62
|
||||
timeCreated: 1748572278
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3f3e6458ad24086b8838b3750453007
|
||||
timeCreated: 1748585143
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc7b116a771640d58d650ff79698f301
|
||||
timeCreated: 1748589438
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
/// <summary>
|
||||
/// 全局各向异性纹理过滤模式
|
||||
/// </summary>
|
||||
[Sort(7)]
|
||||
public class AnisotropicModeSetting : MultiOption<AnisotropicFiltering>
|
||||
{
|
||||
public override string Name => "AnisotropicMode";
|
||||
public override string Group => SettingsDef.Group.Graphic;
|
||||
public override string Tab => SettingsDef.Tab.Graphic;
|
||||
|
||||
protected override int DefaultValue => (int)AnisotropicFiltering.Enable;
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
var enumValues = Enum.GetValues(typeof(AnisotropicFiltering));
|
||||
foreach (var value in enumValues)
|
||||
{
|
||||
AddOption(value.ToString(), (AnisotropicFiltering)value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
// 获取当前URP Asset
|
||||
UniversalRenderPipelineAsset URPAsset =
|
||||
QualitySettings.GetRenderPipelineAssetAt(QualitySettings.GetQualityLevel()) as
|
||||
UniversalRenderPipelineAsset;
|
||||
if (URPAsset)
|
||||
{
|
||||
//全局各向异性纹理过滤模式
|
||||
QualitySettings.anisotropicFiltering = GetSelectedOption();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b96e677183324f5d8d01e786a828c0db
|
||||
timeCreated: 1748590207
|
||||
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
[Sort(1)]
|
||||
public class FullScreenModeSetting : MultiOption<FullScreenMode>
|
||||
{
|
||||
public override string Name => "FullScreenMode";
|
||||
public override string Group => SettingsDef.Group.Graphic;
|
||||
public override string Tab => SettingsDef.Tab.Graphic;
|
||||
protected override int DefaultValue => (int)FullScreenMode.ExclusiveFullScreen;
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
AddOption(nameof(FullScreenMode.ExclusiveFullScreen), FullScreenMode.ExclusiveFullScreen);
|
||||
AddOption(nameof(FullScreenMode.Windowed), FullScreenMode.Windowed);
|
||||
AddOption(nameof(FullScreenMode.FullScreenWindow), FullScreenMode.FullScreenWindow);
|
||||
AddOption(nameof(FullScreenMode.MaximizedWindow), FullScreenMode.MaximizedWindow);
|
||||
}
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
// Screen.fullScreenMode = GetSelectedOption();
|
||||
// Debug.Log($"FullScreenMode: {Screen.fullScreenMode} value: {GetSelectedOption()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a6386dea2d44f3fb004905e688b97d5
|
||||
timeCreated: 1748588770
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public enum AnisotropicLevelEnum
|
||||
{
|
||||
Off = -1,
|
||||
x2 = 2,
|
||||
x4 = 4,
|
||||
x8 = 8,
|
||||
x16 = 16
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 全局各向异性过滤限制
|
||||
/// </summary>
|
||||
[Sort(8)]
|
||||
public class GlobalAnisotropicFilteringLimitsSetting : MultiOption<AnisotropicLevelEnum>
|
||||
{
|
||||
public override string Name => "GlobalAnisotropicFilteringLimits";
|
||||
public override string Group => SettingsDef.Group.Graphic;
|
||||
public override string Tab => SettingsDef.Tab.Graphic;
|
||||
protected override int DefaultValue => (int)AnisotropicLevelEnum.x4;
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
var enumValues = Enum.GetValues(typeof(AnisotropicLevelEnum));
|
||||
foreach (var value in enumValues)
|
||||
{
|
||||
AddOption(value.ToString(), (AnisotropicLevelEnum)value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
// 获取当前URP Asset
|
||||
UniversalRenderPipelineAsset URPAsset =
|
||||
QualitySettings.GetRenderPipelineAssetAt(QualitySettings.GetQualityLevel()) as
|
||||
UniversalRenderPipelineAsset;
|
||||
if (URPAsset)
|
||||
{
|
||||
var current = QualitySettings.anisotropicFiltering;
|
||||
var level = GetSelectedOption();
|
||||
if (current == AnisotropicFiltering.Disable ||
|
||||
current == AnisotropicFiltering.Enable)
|
||||
{
|
||||
Texture.SetGlobalAnisotropicFilteringLimits(-1, -1);
|
||||
}
|
||||
else if (current == AnisotropicFiltering.ForceEnable)
|
||||
{
|
||||
Texture.SetGlobalAnisotropicFilteringLimits((int)level, (int)level);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6937878e8f61426687c62e26252e9258
|
||||
timeCreated: 1748590403
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public enum MsaaSampleEnum
|
||||
{
|
||||
Off = 1,
|
||||
x2 = 2,
|
||||
x4 = 4,
|
||||
x8 = 8
|
||||
}
|
||||
|
||||
[Sort(6)]
|
||||
public class MsaaSampleSetting : MultiOption<MsaaSampleEnum>
|
||||
{
|
||||
public override string Name => "MsaaSample";
|
||||
public override string Group => SettingsDef.Group.Graphic;
|
||||
public override string Tab => SettingsDef.Tab.Graphic;
|
||||
protected override int DefaultValue => (int)MsaaSampleEnum.Off;
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
var enumValues = Enum.GetValues(typeof(MsaaSampleEnum));
|
||||
foreach (var value in enumValues)
|
||||
{
|
||||
AddOption(value.ToString(), (MsaaSampleEnum)value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
// 获取当前URP Asset
|
||||
UniversalRenderPipelineAsset URPAsset =
|
||||
QualitySettings.GetRenderPipelineAssetAt(QualitySettings.GetQualityLevel()) as
|
||||
UniversalRenderPipelineAsset;
|
||||
if (URPAsset)
|
||||
{
|
||||
//抗锯齿等级
|
||||
URPAsset.msaaSampleCount = (int)GetSelectedOption();
|
||||
URPAsset.supportsHDR = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae51922900c9429cb0de97b473a3429e
|
||||
timeCreated: 1748589774
|
||||
@@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
/// <summary>
|
||||
/// 画质设置
|
||||
/// </summary>
|
||||
[Sort(3)]
|
||||
public class QualityLevelSetting : MultiOption<int>
|
||||
{
|
||||
private int _defaultQualityLevel;
|
||||
public override string Name => "QualityLevel";
|
||||
public override string Group => SettingsDef.Group.Graphic;
|
||||
public override string Tab => SettingsDef.Tab.Graphic;
|
||||
protected override int DefaultValue => _defaultQualityLevel;
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
var names = QualitySettings.names;
|
||||
|
||||
for (int i = 0; i < names.Length; i++)
|
||||
{
|
||||
AddOption(names[i], i);
|
||||
}
|
||||
|
||||
_defaultQualityLevel = QualitySettings.GetQualityLevel();
|
||||
}
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
QualitySettings.SetQualityLevel(GetSelectedOption());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 470180f8a41b4856bf3318bc60f2abf1
|
||||
timeCreated: 1748588124
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
[Sort(5)]
|
||||
public class RenderScaleSetting : RangeOption
|
||||
{
|
||||
public override string Name => "RenderScale";
|
||||
public override string Group => SettingsDef.Group.Graphic;
|
||||
public override string Tab => SettingsDef.Tab.Graphic;
|
||||
public override int MinValue => 1;
|
||||
public override int MaxValue => 20;
|
||||
|
||||
protected override int DefaultValue => 10;
|
||||
|
||||
public override int ShowRate => 10;
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
SetValue(10);
|
||||
}
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
// 获取当前URP Asset
|
||||
UniversalRenderPipelineAsset URPAsset =
|
||||
QualitySettings.GetRenderPipelineAssetAt(QualitySettings.GetQualityLevel()) as
|
||||
UniversalRenderPipelineAsset;
|
||||
if (URPAsset)
|
||||
{
|
||||
//渲染比例
|
||||
URPAsset.renderScale = (float)Math.Round(GetValue() / 10f, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e54edac5d4fe4dbda2da5bce433482dc
|
||||
timeCreated: 1748589449
|
||||
@@ -0,0 +1,64 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NBC;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
/// <summary>
|
||||
/// 分辨率设置
|
||||
/// </summary>
|
||||
[Sort(2)]
|
||||
public class ResolutionSetting : MultiOption<Resolution>
|
||||
{
|
||||
private int _defaultResolution;
|
||||
public override string Name => "Resolution";
|
||||
public override string Group => SettingsDef.Group.Graphic;
|
||||
protected override int DefaultValue => _defaultResolution;
|
||||
public override string Tab => SettingsDef.Tab.Graphic;
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
var supportedResolutions = Screen.resolutions
|
||||
.GroupBy(r => $"{r.width}x{r.height}") // 按宽高分组
|
||||
.Select(g => g.OrderByDescending(r => r.refreshRateRatio).First())
|
||||
.ToArray();
|
||||
foreach (var resolution in supportedResolutions)
|
||||
{
|
||||
if (resolution.width < 720 || resolution.height < 720) continue;
|
||||
AddOption($"{resolution.width}x{resolution.height}", resolution);
|
||||
Log.Info($"Resolution {resolution.width}x{resolution.height}");
|
||||
}
|
||||
|
||||
TryGetIndex(t =>
|
||||
t.width == Screen.currentResolution.width && t.height == Screen.currentResolution.height,
|
||||
out _defaultResolution);
|
||||
|
||||
if (_defaultResolution < 0)
|
||||
{
|
||||
_defaultResolution = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
var resolution = GetSelectedOption();
|
||||
Log.Info($"Screen.fullScreenMode {Screen.fullScreenMode}");
|
||||
var mode = FullScreenMode.ExclusiveFullScreen;
|
||||
var screenMode = Root.GetSettingOption<FullScreenModeSetting>();
|
||||
if (screenMode != null)
|
||||
{
|
||||
mode = screenMode.GetSelectedOption();
|
||||
}
|
||||
|
||||
if (mode == FullScreenMode.ExclusiveFullScreen)
|
||||
{
|
||||
Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
Screen.SetResolution(resolution.width, resolution.height, mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08fa420645764519a7a960565464a708
|
||||
timeCreated: 1748586208
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public enum TextureQualityEnum
|
||||
{
|
||||
FullRes = 0,
|
||||
HalfRes = 1,
|
||||
QuarterRes = 2,
|
||||
EighthRes = 3
|
||||
}
|
||||
|
||||
[Sort(9)]
|
||||
public class TextureQualitySetting : MultiOption<TextureQualityEnum>
|
||||
{
|
||||
public override string Name => "TextureQuality";
|
||||
public override string Group => SettingsDef.Group.Graphic;
|
||||
protected override int DefaultValue => (int)TextureQualityEnum.FullRes;
|
||||
public override string Tab => SettingsDef.Tab.Graphic;
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
var enumValues = Enum.GetValues(typeof(TextureQualityEnum));
|
||||
foreach (var value in enumValues)
|
||||
{
|
||||
AddOption(value.ToString(), (TextureQualityEnum)value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
// 获取当前URP Asset
|
||||
UniversalRenderPipelineAsset URPAsset =
|
||||
QualitySettings.GetRenderPipelineAssetAt(QualitySettings.GetQualityLevel()) as
|
||||
UniversalRenderPipelineAsset;
|
||||
if (URPAsset)
|
||||
{
|
||||
//纹理质量
|
||||
QualitySettings.globalTextureMipmapLimit = (int)GetSelectedOption();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7ca1e2468b24b6285be9176ae024864
|
||||
timeCreated: 1748590058
|
||||
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
/// <summary>
|
||||
/// 垂直同步
|
||||
/// </summary>
|
||||
[Sort(4)]
|
||||
public class VSyncSetting : ToggleOption
|
||||
{
|
||||
public override string Name => "VSync";
|
||||
|
||||
public override string Group => SettingsDef.Group.Graphic;
|
||||
public override string Tab => SettingsDef.Tab.Graphic;
|
||||
protected override int DefaultValue => 0;
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
//垂直同步
|
||||
QualitySettings.vSyncCount = GetSelectedOption() ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00628a08aaac416796a4018119e77cc6
|
||||
timeCreated: 1748585191
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f72256d425749e3a05fd57c209d057d
|
||||
timeCreated: 1749539093
|
||||
@@ -0,0 +1,17 @@
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public class InputAddBobSetting : KeyBoardOption
|
||||
{
|
||||
public override string Name => "InputAddBob";
|
||||
public override string Group => SettingsDef.Group.Keyboard;
|
||||
public override string Tab => SettingsDef.Tab.Keyboard;
|
||||
|
||||
public override InputAction InputAction => InputManager.PlayerInputControl.Player.AddBob;
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 673bfd453717403998342a57e58b9b3a
|
||||
timeCreated: 1749634714
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user