修改框架
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ad7c1a3ba27b1144b06e3242a1a64fa
|
||||
guid: 82d391f556304004096b011bbd27de11
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a44844ae79b98fd42a13d84fa3b87f63
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e9a7362d41d8614c910df28f693c782
|
||||
guid: 3da2a5e816dc8054c8c154faf463f46f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08087e76abe4f1a44b1b02c9a716ba1f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 相机模式
|
||||
/// </summary>
|
||||
public enum EnumCameraMode {
|
||||
None,// 无
|
||||
|
||||
// FixedEdit,// 固定编辑
|
||||
|
||||
// FreeEdit,// 自由编辑
|
||||
|
||||
MoveAxis,// 移轴
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e190b0f10e563546bd18df3605da42f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 输入模式
|
||||
/// </summary>
|
||||
public enum EnumInputMode {
|
||||
None,// 无
|
||||
|
||||
// FixedEdit,// 固定编辑
|
||||
|
||||
// FixedPreview,// 固定编辑
|
||||
|
||||
// FreeEdit,// 自由编辑
|
||||
|
||||
Standard,// 第三人称
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fc2f524dbb594a40a4a13d3d253c53e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 页面类型
|
||||
/// </summary>
|
||||
public enum EnumPage {
|
||||
None,
|
||||
|
||||
Menu,// 主菜单
|
||||
Scene,// 场景选择
|
||||
Prepare,// 准备游戏
|
||||
Battle,// 战斗页面
|
||||
Settlement,// 结算页面
|
||||
|
||||
Settings,// 游戏设置
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 398ffa613e85ac24b9a554499e7d6784
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 运行模式
|
||||
/// </summary>
|
||||
public enum EnumRunningMode {
|
||||
None,// 无模式
|
||||
|
||||
Standard,// 标准模式
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 043dda22a291d664fa2124109ddc8dd6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d43d8ee099053249a2aba58d719bf26
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 游戏管理
|
||||
/// </summary>
|
||||
public class SingleManager : ModuleSingle<SingleManager> {
|
||||
|
||||
/// <summary> 运行模式 </summary>
|
||||
public static EnumRunningMode runningMode;
|
||||
|
||||
/// <summary> 设置运行模式 </summary>
|
||||
public static void SetRunningMode(EnumRunningMode runningMode) {
|
||||
SingleManager.runningMode = runningMode;
|
||||
}
|
||||
|
||||
protected override void Awake() {
|
||||
NoReplace();
|
||||
// ManagerScene.OnComplete += ManagerScene_OnComplete;
|
||||
}
|
||||
private void Start() {
|
||||
// ModuleUI.Jump(EnumPage.Menu);
|
||||
// ModuleInput.Mode(EnumInputMode.None);
|
||||
// ModuleCamera.Mode(EnumCameraMode.None);
|
||||
// SceneManager.LoadScene("MenuScene");
|
||||
}
|
||||
|
||||
private void ManagerScene_OnComplete() {
|
||||
// if (runningMode == EnumRunningMode.None) {
|
||||
// ModuleUI.Jump(EnumPage.Menu);
|
||||
// ModuleInput.Mode(EnumInputMode.None);
|
||||
// ModuleCamera.Mode(EnumCameraMode.None);
|
||||
// }
|
||||
// if (runningMode == EnumRunningMode.Standard) {
|
||||
// ModuleUI.Jump(EnumPage.Battle);
|
||||
// // ModuleInput.Mode(EnumInputMode.ThirdPerson);
|
||||
// // ModuleCamera.Mode(EnumCameraMode.ThirdPerson);
|
||||
// }
|
||||
}
|
||||
|
||||
public void StartGame() {
|
||||
// ManagerScene.LoadScene(null);
|
||||
// ModuleUI.Jump(EnumPage.Battle);
|
||||
// ModuleInput.Mode(EnumInputMode.Standard);
|
||||
// ModuleCamera.Mode(EnumCameraMode.MoveAxis);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 583ea9bd27e0e034d89711b923d7f4a1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50b48c8fb325a394db1ead28dc81b13f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,125 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
/// <summary>
|
||||
/// 可视控制台
|
||||
/// </summary>
|
||||
public class GameViewConsole : MonoBehaviour {
|
||||
|
||||
private struct Log {
|
||||
public string Message;
|
||||
public string StackTrace;
|
||||
public LogType LogType;
|
||||
}
|
||||
|
||||
|
||||
#region Inspector 面板属性
|
||||
|
||||
[Tooltip("摇动开启控制台?")] public bool ShakeToOpen = true;
|
||||
[Tooltip("窗口打开加速度")] public float shakeAcceleration = 3f;
|
||||
[Tooltip("是否保持一定数量的日志")] public bool restrictLogCount = false;
|
||||
[Tooltip("最大日志数")] public int maxLogs = 1000;
|
||||
|
||||
#endregion
|
||||
|
||||
private readonly List<Log> logs = new List<Log>();
|
||||
private Log log;
|
||||
private Vector2 scrollPosition;
|
||||
private bool visible;
|
||||
public bool collapse;
|
||||
|
||||
private static readonly Dictionary<LogType, Color> logTypeColors = new Dictionary<LogType, Color>
|
||||
{
|
||||
{LogType.Assert, Color.white},
|
||||
{LogType.Error, Color.red},
|
||||
{LogType.Exception, Color.red},
|
||||
{LogType.Log, Color.white},
|
||||
{LogType.Warning, Color.yellow},
|
||||
};
|
||||
|
||||
private const string ChinarWindowTitle = "服务器-控制台";
|
||||
private const int Edge = 20;
|
||||
private readonly GUIContent clearLabel = new GUIContent("清空", "清空控制台内容");
|
||||
private readonly GUIContent hiddenLabel = new GUIContent("合并信息", "隐藏重复信息");
|
||||
|
||||
private readonly Rect titleBarRect = new Rect(0, 0, 10000, 20);
|
||||
private Rect windowRect = new Rect(Edge, Edge, Screen.width - (Edge * 2), Screen.height * 0.5f - (Edge * 2));
|
||||
|
||||
|
||||
private void OnEnable() {
|
||||
Application.logMessageReceived += HandleLog;
|
||||
}
|
||||
|
||||
|
||||
private void OnDisable() {
|
||||
Application.logMessageReceived -= HandleLog;
|
||||
}
|
||||
|
||||
|
||||
private void Update() {
|
||||
if (ShakeToOpen && Input.acceleration.sqrMagnitude > shakeAcceleration) visible = true;
|
||||
}
|
||||
|
||||
|
||||
private void OnGUI() {
|
||||
if (!visible) return;
|
||||
windowRect = GUILayout.Window(666, windowRect, DrawConsoleWindow, ChinarWindowTitle);
|
||||
}
|
||||
|
||||
public void OnSwitchView(InputValue inputValue) {
|
||||
visible = !visible;
|
||||
}
|
||||
|
||||
private void DrawConsoleWindow(int windowid) {
|
||||
DrawLogsList();
|
||||
DrawToolbar();
|
||||
GUI.DragWindow(titleBarRect);
|
||||
}
|
||||
|
||||
|
||||
private void DrawLogsList() {
|
||||
scrollPosition = GUILayout.BeginScrollView(scrollPosition);
|
||||
for (var i = 0; i < logs.Count; i++) {
|
||||
if (collapse && i > 0) if (logs[i].Message != logs[i - 1].Message) continue;
|
||||
GUI.contentColor = logTypeColors[logs[i].LogType];
|
||||
GUILayout.Label(logs[i].Message);
|
||||
}
|
||||
GUILayout.EndScrollView();
|
||||
GUI.contentColor = Color.white;
|
||||
}
|
||||
|
||||
|
||||
private void DrawToolbar() {
|
||||
GUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button(clearLabel)) {
|
||||
logs.Clear();
|
||||
}
|
||||
|
||||
collapse = GUILayout.Toggle(collapse, hiddenLabel, GUILayout.ExpandWidth(false));
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
|
||||
private void HandleLog(string message, string stackTrace, LogType type) {
|
||||
logs.Add(new Log {
|
||||
Message = message,
|
||||
StackTrace = stackTrace,
|
||||
LogType = type,
|
||||
});
|
||||
DeleteExcessLogs();
|
||||
}
|
||||
|
||||
|
||||
private void DeleteExcessLogs() {
|
||||
if (!restrictLogCount) return;
|
||||
var amountToRemove = Mathf.Max(logs.Count - maxLogs, 0);
|
||||
print(amountToRemove);
|
||||
if (amountToRemove == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
logs.RemoveRange(0, amountToRemove);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17521a3fbf0da654cb1743fe94350289
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,14 +1,24 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// UI模块
|
||||
/// </summary>
|
||||
public class ModuleUI : ModuleSingle<ModuleUI> {
|
||||
public static EnumPage page;
|
||||
public static event Action<EnumPage> OnJumpPage;
|
||||
|
||||
public UIDocument document;// 绑定文档
|
||||
|
||||
/// <summary> 根目录文档 </summary>
|
||||
public VisualElement root => document.rootVisualElement;
|
||||
|
||||
protected override void Awake() => NoReplace();
|
||||
|
||||
/// <summary> 跳转页面 </summary>
|
||||
public static void Jump(EnumPage pageType) => OnJumpPage?.Invoke(pageType);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 217b5fdf76c9e1e4abbb9bd77f28883e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6367a8584682b4448e1412bc5492272
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 可视化模块
|
||||
/// </summary>
|
||||
public class ModuleVisual : ModuleSingle<ModuleVisual> {
|
||||
|
||||
// public VisualController<KinesisController> KinesisController;
|
||||
|
||||
protected override void Awake() => NoReplace();
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aff4fda1c9fd8164384489f6750e34f4
|
||||
guid: 925869fcfe1fe4c4fa159c8cbf3314b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 可视化控制器
|
||||
/// </summary>
|
||||
public abstract class VisualController<T> : MonoBehaviour {
|
||||
/// <summary> 更新可视化内容 </summary>
|
||||
public abstract void UpdateVisual(ref T visual);
|
||||
/// <summary> 释放可视化内容 </summary>
|
||||
public abstract void ReleaseVisual(T visual);
|
||||
|
||||
/// <summary> 创建可视化内容 </summary>
|
||||
public static void Create<Type>(ref Type value, Transform original, Transform parent) {
|
||||
if (value != null) { return; }
|
||||
Transform temp = Instantiate(original, parent);
|
||||
temp.gameObject.SetActive(true);
|
||||
value = temp.GetComponent<Type>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f5703f8ca1d43d479d541a0a08552e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,27 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 数据可视化
|
||||
/// </summary>
|
||||
public class ModuleVisual {
|
||||
/// <summary> 创建可视化内容 </summary>
|
||||
public static void Create<Type>(ref Type value, Transform original, Transform parent) {
|
||||
if (value != null) { return; }
|
||||
Transform temp = CreateTransform(original, parent);
|
||||
value = temp.GetComponent<Type>();
|
||||
}
|
||||
/// <summary> 创建Transform </summary>
|
||||
public static Transform CreateTransform(Transform original, Transform parent) {
|
||||
Transform temp = Transform.Instantiate(original, parent);
|
||||
temp.gameObject.SetActive(true);
|
||||
return temp;
|
||||
}
|
||||
/// <summary> 删除可视化内容 </summary>
|
||||
public static void Remove<Type>(Type visual) where Type : Component {
|
||||
if (visual != null) { GameObject.Destroy(visual.gameObject); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,11 @@ using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace MuHua
|
||||
{
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 轮廓渲染设置
|
||||
/// </summary>
|
||||
public class SRFOutlineSettings
|
||||
{
|
||||
public class SRFOutlineSettings {
|
||||
/// <summary> 辅助材质 </summary>
|
||||
public Material unlit;
|
||||
/// <summary> 轮廓材质 </summary>
|
||||
@@ -25,8 +23,7 @@ namespace MuHua
|
||||
/// <summary>
|
||||
/// 轮廓渲染通道
|
||||
/// </summary>
|
||||
public class SRFOutlinePass : ScriptableRenderPass
|
||||
{
|
||||
public class SRFOutlinePass : ScriptableRenderPass {
|
||||
public const string ProfilerTag = "Outline";
|
||||
|
||||
/// <summary> 渲染设置 </summary>
|
||||
@@ -38,8 +35,7 @@ namespace MuHua
|
||||
public RTHandle outlineRTHandle;
|
||||
|
||||
/// <summary> 渲染前设置 </summary>
|
||||
public void Setup(SRFOutlineSettings settings, in RenderingData renderingData)
|
||||
{
|
||||
public void Setup(SRFOutlineSettings settings, in RenderingData renderingData) {
|
||||
this.settings = settings;
|
||||
renderPassEvent = settings.renderPassEvent;
|
||||
RenderTextureDescriptor descriptor = renderingData.cameraData.cameraTargetDescriptor;
|
||||
@@ -48,8 +44,7 @@ namespace MuHua
|
||||
RenderingUtils.ReAllocateIfNeeded(ref tempRTHandle, descriptor, name: "TempRT");
|
||||
}
|
||||
|
||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
||||
{
|
||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) {
|
||||
if (renderingData.cameraData.cameraType == CameraType.SceneView || renderingData.cameraData.cameraType == CameraType.Preview) return;
|
||||
|
||||
CommandBuffer command = CommandBufferPool.Get(ProfilerTag);
|
||||
@@ -78,16 +73,13 @@ namespace MuHua
|
||||
outlineRTHandle?.Release();
|
||||
}
|
||||
|
||||
public void DrawRenderer(CommandBuffer command, Material material)
|
||||
{
|
||||
for (int i = 0; i < settings.renderObjs.Length; i++)
|
||||
{
|
||||
public void DrawRenderer(CommandBuffer command, Material material) {
|
||||
for (int i = 0; i < settings.renderObjs.Length; i++) {
|
||||
Renderer renderer = settings.renderObjs[i];
|
||||
if (renderer == null) { continue; }
|
||||
|
||||
// 遍历所有的子网格
|
||||
for (int subMeshIndex = 0; subMeshIndex < renderer.sharedMaterials.Length; subMeshIndex++)
|
||||
{
|
||||
for (int subMeshIndex = 0; subMeshIndex < renderer.sharedMaterials.Length; subMeshIndex++) {
|
||||
command.DrawRenderer(renderer, material, subMeshIndex, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user