33014
Assets/FR2_Cache.asset
33014
Assets/FR2_Cache.asset
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,8 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ichni.RhythmGame; // 假设 LeanPool 引用在这里或 Lean.Pool 命名空间
|
||||
using Lean.Pool; // 引入 LeanPool
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.Editor
|
||||
@@ -10,364 +10,317 @@ namespace Ichni.Editor
|
||||
[RequireComponent(typeof(MeshRenderer))]
|
||||
public class EditorGrid : MonoBehaviour
|
||||
{
|
||||
[Tooltip("指定用于计算缩放的摄像机(若为空则使用 Camera.main)")]
|
||||
public GridController gridController;
|
||||
[Header("Camera Settings")]
|
||||
public Camera sceneCamera;
|
||||
|
||||
public float cameraDistance;
|
||||
|
||||
[Tooltip("指定网格所在的平面:0 = XZ (y=0), 1 = XY (z=0), 2 = YZ (x=0)")]
|
||||
[Header("Grid Configuration")]
|
||||
[Tooltip("0 = XZ, 1 = XY, 2 = YZ")]
|
||||
public int gridPlane = 0;
|
||||
|
||||
[Tooltip("网格基础缩放值,单位 1")]
|
||||
public float baseScale = 1f;
|
||||
|
||||
[Tooltip("调整缩放的影响因子,建议值 1~5")]
|
||||
public float scaleMultiplier = 1f;
|
||||
|
||||
[Tooltip("距离因子,用于计算对数缩放(例如距离大于该值时切换到下一级单位)")]
|
||||
public float distanceFactor = 10f;
|
||||
|
||||
[Tooltip("位置文本更新频率(秒)")]
|
||||
public float textUpdateFrequency = 0.1f;
|
||||
|
||||
[FormerlySerializedAs("showPositionText")]
|
||||
[Header("Text Settings")]
|
||||
public bool canShowPositionText;
|
||||
|
||||
public bool isShowingPositionText;
|
||||
public Transform textContainer;
|
||||
public GameObject positionTextPrefab;
|
||||
|
||||
// 内部缓存材质
|
||||
[Tooltip("启用此项可让文字在屏幕上保持固定大小")]
|
||||
public bool constantScreenSize = true;
|
||||
[Tooltip("屏幕固定大小的基准系数")]
|
||||
public float fixedTextSizeFactor => gridController != null ? gridController.fixedTextSizeFactor : 0.02f;
|
||||
|
||||
public float textUpdateFrequency = 0.1f;
|
||||
|
||||
// --- 运行时状态 ---
|
||||
private Material gridMaterial;
|
||||
public Dictionary<GameObject, Vector3> positionTexts = new Dictionary<GameObject, Vector3>();
|
||||
private float cameraDistance;
|
||||
public float logScale;
|
||||
public float gridScale;
|
||||
|
||||
// 对象池相关
|
||||
private Queue<GameObject> textPool = new Queue<GameObject>();
|
||||
private const int POOL_SIZE = 50;
|
||||
|
||||
// 性能优化缓存
|
||||
private float lastTextUpdateTime = 0f;
|
||||
// --- 缓存与优化变量 ---
|
||||
private float lastTextUpdateTime;
|
||||
private Vector3 lastCameraPosition;
|
||||
private float lastGridScale;
|
||||
private Plane gridPlaneCache;
|
||||
private Vector2 screenCenter;
|
||||
|
||||
public float logScale;
|
||||
public float gridScale; // 1, 4, 16, 64...
|
||||
// 使用 Vector2Int 作为 Key,避免浮点数比较误差,同时实现 O(1) 查找
|
||||
// Key: 网格索引 (x index, z index), Value: 文本对象
|
||||
private Dictionary<Vector2Int, GameObject> activeTexts = new Dictionary<Vector2Int, GameObject>();
|
||||
|
||||
// 避免 GC 的复用容器
|
||||
private HashSet<Vector2Int> requiredIndices = new HashSet<Vector2Int>();
|
||||
private List<Vector2Int> toRemoveIndices = new List<Vector2Int>();
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
InitializeTextPool();
|
||||
|
||||
sceneCamera = EditorManager.instance.cameraManager.sceneCamera.sceneCamera;
|
||||
// 实例化材质,避免修改共享材质
|
||||
gridMaterial = GetComponent<MeshRenderer>().material;
|
||||
// 同步网格平面的值到材质(方便 Shader 内部判断)
|
||||
gridMaterial.SetFloat("_Plane", gridPlane);
|
||||
|
||||
// 设置 Shader 线宽
|
||||
float lineWidthOf3840 = 2;
|
||||
float screenWidth = Screen.width;
|
||||
float lineWidth = lineWidthOf3840 * (screenWidth / 3840f);
|
||||
float lineWidth = lineWidthOf3840 * (Screen.width / 3840f);
|
||||
gridMaterial.SetFloat("_LineWidth", lineWidth);
|
||||
|
||||
// 预计算屏幕中心
|
||||
screenCenter = new Vector2(Screen.width / 2f, Screen.height / 2f);
|
||||
|
||||
// 预计算网格平面
|
||||
UpdateGridPlaneCache();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
sceneCamera = EditorManager.instance.cameraManager.currentCamera;
|
||||
// 获取当前相机
|
||||
if (EditorManager.instance?.cameraManager?.currentCamera != null)
|
||||
sceneCamera = EditorManager.instance.cameraManager.currentCamera;
|
||||
|
||||
// 计算摄像机到网格平面的垂直距离
|
||||
cameraDistance = 0f;
|
||||
Vector3 camPos = sceneCamera.transform.position;
|
||||
Vector3 gridPos = transform.position;
|
||||
switch (gridPlane)
|
||||
{
|
||||
case 0: // XZ 平面:垂直方向为 Y
|
||||
cameraDistance = Mathf.Abs(camPos.y - gridPos.y);
|
||||
break;
|
||||
case 1: // XY 平面:垂直方向为 Z
|
||||
cameraDistance = Mathf.Abs(camPos.z - gridPos.z);
|
||||
break;
|
||||
case 2: // YZ 平面:垂直方向为 X
|
||||
cameraDistance = Mathf.Abs(camPos.x - gridPos.x);
|
||||
break;
|
||||
}
|
||||
if (sceneCamera == null) return;
|
||||
|
||||
// 利用对数函数计算缩放等级:距离越远,网格越大
|
||||
logScale = Mathf.Floor(Mathf.Log(cameraDistance / distanceFactor + 1, 4));
|
||||
gridScale = baseScale * Mathf.Pow(4, logScale) * scaleMultiplier;
|
||||
|
||||
gridMaterial.SetFloat("_GridScale", 1 / gridScale);
|
||||
gridMaterial.SetFloat("_DisappearEndDistance", 100 * gridScale);
|
||||
CalculateGridScale();
|
||||
UpdateShaderParams();
|
||||
|
||||
if (canShowPositionText && isShowingPositionText)
|
||||
{
|
||||
// 添加更新频率控制
|
||||
// 检查是否需要更新网格位置(降低频率)
|
||||
bool shouldUpdate = Time.time - lastTextUpdateTime >= textUpdateFrequency ||
|
||||
Vector3.Distance(sceneCamera.transform.position, lastCameraPosition) > gridScale * 0.5f ||
|
||||
Mathf.Abs(gridScale - lastGridScale) > 0.1f;
|
||||
Vector3.Distance(sceneCamera.transform.position, lastCameraPosition) > gridScale * 0.5f ||
|
||||
Mathf.Abs(gridScale - lastGridScale) > 0.1f;
|
||||
|
||||
if (shouldUpdate)
|
||||
{
|
||||
GetPoints();
|
||||
UpdateTextPositions();
|
||||
lastTextUpdateTime = Time.time;
|
||||
lastCameraPosition = sceneCamera.transform.position;
|
||||
lastGridScale = gridScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 只更新文本朝向(性能较轻)
|
||||
UpdateTextOrientations();
|
||||
}
|
||||
}
|
||||
else if (isShowingPositionText && !canShowPositionText)
|
||||
else if (activeTexts.Count > 0)
|
||||
{
|
||||
ClearAllTexts();
|
||||
isShowingPositionText = false;
|
||||
}
|
||||
}
|
||||
|
||||
#region 文本显示优化
|
||||
|
||||
private void InitializeTextPool()
|
||||
// 使用 LateUpdate 处理文字的朝向和缩放,防止画面抖动
|
||||
void LateUpdate()
|
||||
{
|
||||
for (int i = 0; i < POOL_SIZE; i++)
|
||||
{
|
||||
GameObject textObj = Instantiate(positionTextPrefab, textContainer);
|
||||
textObj.transform.localScale = Vector3.zero; // 重置缩放
|
||||
textPool.Enqueue(textObj);
|
||||
}
|
||||
if (!canShowPositionText || !isShowingPositionText || activeTexts.Count == 0) return;
|
||||
|
||||
UpdateTextVisuals();
|
||||
}
|
||||
|
||||
private GameObject GetTextFromPool()
|
||||
private void CalculateGridScale()
|
||||
{
|
||||
if (textPool.Count > 0)
|
||||
Vector3 camPos = sceneCamera.transform.position;
|
||||
Vector3 gridPos = transform.position;
|
||||
|
||||
cameraDistance = gridPlane switch
|
||||
{
|
||||
GameObject textObj = textPool.Dequeue();
|
||||
textObj.transform.localScale = Vector3.one; // 重置缩放
|
||||
return textObj;
|
||||
0 => Mathf.Abs(camPos.y - gridPos.y), // XZ
|
||||
1 => Mathf.Abs(camPos.z - gridPos.z), // XY
|
||||
2 => Mathf.Abs(camPos.x - gridPos.x), // YZ
|
||||
_ => cameraDistance
|
||||
};
|
||||
|
||||
logScale = Mathf.Floor(Mathf.Log(cameraDistance / distanceFactor + 1, 4));
|
||||
gridScale = baseScale * Mathf.Pow(4, logScale) * scaleMultiplier;
|
||||
}
|
||||
|
||||
private void UpdateShaderParams()
|
||||
{
|
||||
gridMaterial.SetFloat("_GridScale", 1 / gridScale);
|
||||
gridMaterial.SetFloat("_DisappearEndDistance", 100 * gridScale);
|
||||
}
|
||||
|
||||
#region 文本逻辑 (优化版)
|
||||
|
||||
private void UpdateTextPositions()
|
||||
{
|
||||
// 每次都获取最新的屏幕中心,保证中心点始终正确
|
||||
screenCenter = new Vector2(Screen.width / 2f, Screen.height / 2f);
|
||||
// 1. 射线检测找中心点
|
||||
Ray sceneCameraRay = sceneCamera.ScreenPointToRay(screenCenter);
|
||||
if (!gridPlaneCache.Raycast(sceneCameraRay, out float enter))
|
||||
{
|
||||
ClearAllTexts();
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果池子空了,动态创建一个(应该很少发生)
|
||||
GameObject newTextObj = Instantiate(positionTextPrefab, textContainer);
|
||||
return newTextObj;
|
||||
}
|
||||
Vector3 centerPoint = sceneCameraRay.GetPoint(enter);
|
||||
|
||||
private void ReturnTextToPool(GameObject textObj)
|
||||
{
|
||||
textObj.transform.localScale = Vector3.zero; // 重置缩放;
|
||||
textPool.Enqueue(textObj);
|
||||
}
|
||||
|
||||
private void UpdateTextOrientations()
|
||||
{
|
||||
foreach (var textObj in positionTexts.Keys)
|
||||
// 距离剔除
|
||||
if (Vector3.Distance(sceneCamera.transform.position, centerPoint) > 200f) // 增加最大距离
|
||||
{
|
||||
if (textObj != null && textObj.activeInHierarchy)
|
||||
ClearAllTexts();
|
||||
return;
|
||||
}
|
||||
|
||||
float radius = gridScale * 12f; // 可视范围半径
|
||||
float step = gridScale * 4f; // 网格步长
|
||||
|
||||
// 2. 计算当前需要的网格索引范围
|
||||
requiredIndices.Clear();
|
||||
|
||||
// 根据不同的平面,取不同的轴进行计算
|
||||
float xLocal = 0, yLocal = 0;
|
||||
switch (gridPlane)
|
||||
{
|
||||
case 0: xLocal = centerPoint.x; yLocal = centerPoint.z; break; // XZ
|
||||
case 1: xLocal = centerPoint.x; yLocal = centerPoint.y; break; // XY
|
||||
case 2: xLocal = centerPoint.y; yLocal = centerPoint.z; break; // YZ (注意轴向)
|
||||
}
|
||||
|
||||
int minX = Mathf.FloorToInt((xLocal - radius) / step);
|
||||
int maxX = Mathf.CeilToInt((xLocal + radius) / step);
|
||||
int minY = Mathf.FloorToInt((yLocal - radius) / step);
|
||||
int maxY = Mathf.CeilToInt((yLocal + radius) / step);
|
||||
|
||||
for (int x = minX; x <= maxX; x++)
|
||||
{
|
||||
for (int y = minY; y <= maxY; y++)
|
||||
{
|
||||
Vector3 direction = sceneCamera.transform.position - textObj.transform.position;
|
||||
textObj.transform.forward = -direction.normalized;
|
||||
requiredIndices.Add(new Vector2Int(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 移除不再需要的 (差集)
|
||||
toRemoveIndices.Clear();
|
||||
foreach (var kvp in activeTexts)
|
||||
{
|
||||
if (!requiredIndices.Contains(kvp.Key))
|
||||
{
|
||||
toRemoveIndices.Add(kvp.Key);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var key in toRemoveIndices)
|
||||
{
|
||||
LeanPool.Despawn(activeTexts[key]);
|
||||
activeTexts.Remove(key);
|
||||
}
|
||||
|
||||
// 4. 生成新增的
|
||||
foreach (var index in requiredIndices)
|
||||
{
|
||||
if (!activeTexts.ContainsKey(index))
|
||||
{
|
||||
SpawnTextAt(index, step);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearAllTexts()
|
||||
private void SpawnTextAt(Vector2Int index, float step)
|
||||
{
|
||||
foreach (var textObj in positionTexts.Keys)
|
||||
GameObject textObj = LeanPool.Spawn(positionTextPrefab, textContainer);
|
||||
|
||||
// 计算世界坐标
|
||||
Vector3 worldPos = Vector3.zero;
|
||||
float xPos = index.x * step;
|
||||
float yPos = index.y * step;
|
||||
|
||||
// 偏移量:稍微偏离网格线
|
||||
float offset = gridScale / 6f;
|
||||
|
||||
switch (gridPlane)
|
||||
{
|
||||
if (textObj != null)
|
||||
case 0: // XZ
|
||||
worldPos = new Vector3(xPos + offset, transform.position.y, yPos + offset);
|
||||
break;
|
||||
case 1: // XY
|
||||
worldPos = new Vector3(xPos + offset, yPos + offset, transform.position.z);
|
||||
break;
|
||||
case 2: // YZ -> 这里 index.x 对应 Y轴, index.y 对应 Z轴 (视具体需求调整)
|
||||
worldPos = new Vector3(transform.position.x, xPos + offset, yPos + offset);
|
||||
break;
|
||||
}
|
||||
|
||||
textObj.transform.position = worldPos;
|
||||
|
||||
// 设置文本内容
|
||||
TMP_Text tmp = textObj.GetComponent<TMP_Text>();
|
||||
if (tmp) tmp.text = $"({Mathf.RoundToInt(xPos)}, {Mathf.RoundToInt(yPos)})";
|
||||
|
||||
activeTexts.Add(index, textObj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理朝向摄像机 和 动态大小
|
||||
/// </summary>
|
||||
private void UpdateTextVisuals()
|
||||
{
|
||||
Vector3 camPos = sceneCamera.transform.position;
|
||||
|
||||
foreach (var kvp in activeTexts)
|
||||
{
|
||||
GameObject obj = kvp.Value;
|
||||
if (obj == null) continue;
|
||||
|
||||
Transform t = obj.transform;
|
||||
float dist = Vector3.Distance(camPos, t.position);
|
||||
|
||||
// 1. 朝向摄像机
|
||||
t.LookAt(t.position + sceneCamera.transform.rotation * Vector3.forward,
|
||||
sceneCamera.transform.rotation * Vector3.up);
|
||||
|
||||
// 2. 动态计算大小
|
||||
if (constantScreenSize)
|
||||
{
|
||||
ReturnTextToPool(textObj);
|
||||
// 简单的透视投影公式:大小 = 距离 * 系数
|
||||
// 这样距离越远,物体本身越大,但在屏幕上看起来一样大
|
||||
float finalScale = dist * fixedTextSizeFactor;
|
||||
t.localScale = new Vector3(finalScale, finalScale, finalScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 原有的逻辑:随网格等级缩放
|
||||
float staticScale = gridScale * 1.5f;
|
||||
t.localScale = new Vector3(staticScale, staticScale, staticScale);
|
||||
}
|
||||
}
|
||||
positionTexts.Clear();
|
||||
}
|
||||
|
||||
public void ClearAllTexts()
|
||||
{
|
||||
foreach (var obj in activeTexts.Values)
|
||||
{
|
||||
if (obj != null) LeanPool.Despawn(obj);
|
||||
}
|
||||
activeTexts.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 网格点计算优化
|
||||
|
||||
void GetPoints()
|
||||
{
|
||||
// 使用平面射线检测替代 Physics.Raycast(性能更好)
|
||||
Ray sceneCameraRay = sceneCamera.ScreenPointToRay(screenCenter);
|
||||
|
||||
if (gridPlaneCache.Raycast(sceneCameraRay, out float enter))
|
||||
{
|
||||
Vector3 point = sceneCameraRay.GetPoint(enter);
|
||||
|
||||
// 添加距离检查,太远就不显示文本
|
||||
float distanceToCamera = Vector3.Distance(sceneCamera.transform.position, point);
|
||||
if (distanceToCamera > 50f)
|
||||
{
|
||||
ClearAllTexts();
|
||||
return;
|
||||
}
|
||||
|
||||
float radius = gridScale * 16f;
|
||||
float step = gridScale * 4f;
|
||||
|
||||
// 计算可见区域边界
|
||||
Vector2Int minMaxX = CalculateBounds(point.x, radius, step);
|
||||
Vector2Int minMaxZ = CalculateBounds(point.z, radius, step);
|
||||
|
||||
// 使用 HashSet 来跟踪需要显示的位置(避免重复计算)
|
||||
HashSet<Vector3> requiredPositions = new HashSet<Vector3>();
|
||||
|
||||
for (int x = minMaxX.x; x <= minMaxX.y; x++)
|
||||
{
|
||||
for (int z = minMaxZ.x; z <= minMaxZ.y; z++)
|
||||
{
|
||||
Vector3 position = new Vector3(x * step, 0, z * step);
|
||||
requiredPositions.Add(position);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateTextDisplay(requiredPositions);
|
||||
}
|
||||
}
|
||||
|
||||
// 辅助方法:计算边界(避免重复的数学运算)
|
||||
private Vector2Int CalculateBounds(float center, float radius, float step)
|
||||
{
|
||||
int min = Mathf.FloorToInt((center - radius) / step);
|
||||
int max = Mathf.CeilToInt((center + radius) / step);
|
||||
return new Vector2Int(min, max);
|
||||
}
|
||||
|
||||
// 更新网格平面缓存
|
||||
private void UpdateGridPlaneCache()
|
||||
{
|
||||
gridPlaneCache = gridPlane switch
|
||||
{
|
||||
0 => new Plane(Vector3.up, transform.position), // XZ
|
||||
1 => new Plane(Vector3.forward, transform.position), // XY
|
||||
2 => new Plane(Vector3.right, transform.position), // YZ
|
||||
0 => new Plane(Vector3.up, transform.position),
|
||||
1 => new Plane(Vector3.forward, transform.position),
|
||||
2 => new Plane(Vector3.right, transform.position),
|
||||
_ => new Plane(Vector3.up, transform.position)
|
||||
};
|
||||
}
|
||||
|
||||
private void UpdateTextDisplay(HashSet<Vector3> requiredPositions)
|
||||
{
|
||||
// 第一步:移除不再需要的位置文本
|
||||
List<GameObject> toRemove = new List<GameObject>();
|
||||
foreach (var kvp in positionTexts)
|
||||
{
|
||||
if (!requiredPositions.Contains(kvp.Value))
|
||||
{
|
||||
toRemove.Add(kvp.Key);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (GameObject textObj in toRemove)
|
||||
{
|
||||
positionTexts.Remove(textObj);
|
||||
ReturnTextToPool(textObj);
|
||||
}
|
||||
|
||||
// 第二步:添加新位置文本
|
||||
foreach (Vector3 position in requiredPositions)
|
||||
{
|
||||
if (!ContainsPosition(position))
|
||||
{
|
||||
GameObject textObj = GetTextFromPool();
|
||||
SetupTextObject(textObj, position);
|
||||
positionTexts[textObj] = position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool ContainsPosition(Vector3 position)
|
||||
{
|
||||
foreach (var pos in positionTexts.Values)
|
||||
{
|
||||
if (Vector3.Distance(pos, position) < 0.1f)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SetupTextObject(GameObject textObj, Vector3 position)
|
||||
{
|
||||
textObj.transform.position = position + new Vector3(gridScale / 6, 0, gridScale / 12);
|
||||
|
||||
float scaleFactor = gridScale * 1.5f;
|
||||
textObj.transform.localScale = new Vector3(scaleFactor, scaleFactor, scaleFactor);
|
||||
|
||||
// 设置文本内容
|
||||
TMP_Text tmpText = textObj.GetComponent<TMP_Text>();
|
||||
if (tmpText != null)
|
||||
{
|
||||
tmpText.text = $"({Mathf.RoundToInt(position.x)}, {Mathf.RoundToInt(position.z)})";
|
||||
}
|
||||
|
||||
// 初始朝向
|
||||
Vector3 direction = sceneCamera.transform.position - textObj.transform.position;
|
||||
textObj.transform.forward = -direction.normalized;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 公共方法
|
||||
|
||||
public void ShowPositionText()
|
||||
{
|
||||
canShowPositionText = true;
|
||||
isShowingPositionText = true;
|
||||
lastTextUpdateTime = 0; // 强制下一次更新
|
||||
}
|
||||
|
||||
public void HidePositionText()
|
||||
{
|
||||
canShowPositionText = false;
|
||||
ClearAllTexts();
|
||||
}
|
||||
|
||||
public void SetGridPlane(int planeIndex)
|
||||
{
|
||||
if (planeIndex >= 0 && planeIndex <= 2)
|
||||
{
|
||||
gridPlane = planeIndex;
|
||||
gridMaterial.SetFloat("_Plane", gridPlane);
|
||||
UpdateGridPlaneCache();
|
||||
}
|
||||
gridPlane = planeIndex;
|
||||
gridMaterial.SetFloat("_Plane", gridPlane);
|
||||
UpdateGridPlaneCache();
|
||||
// 切换平面时强制刷新文字
|
||||
ClearAllTexts();
|
||||
lastTextUpdateTime = 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
// 清理资源
|
||||
if (gridMaterial != null)
|
||||
{
|
||||
if (Application.isEditor)
|
||||
DestroyImmediate(gridMaterial);
|
||||
else
|
||||
Destroy(gridMaterial);
|
||||
if (Application.isEditor) DestroyImmediate(gridMaterial);
|
||||
else Destroy(gridMaterial);
|
||||
}
|
||||
|
||||
ClearAllTexts();
|
||||
|
||||
// 清理对象池
|
||||
foreach (var textObj in textPool)
|
||||
{
|
||||
if (textObj != null)
|
||||
{
|
||||
if (Application.isEditor)
|
||||
DestroyImmediate(textObj);
|
||||
else
|
||||
Destroy(textObj);
|
||||
}
|
||||
}
|
||||
textPool.Clear();
|
||||
// 场景销毁时,LeanPool 通常会自动清理,但手动清理引用是个好习惯
|
||||
activeTexts.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.Editor
|
||||
@@ -16,59 +13,64 @@ namespace Ichni.Editor
|
||||
public EditorGrid xPlaneGrid;
|
||||
public EditorGrid zPlaneGrid;
|
||||
|
||||
public bool yPlaneEnabled;
|
||||
public bool xPlaneEnabled;
|
||||
public bool zPlaneEnabled;
|
||||
[Header("State")]
|
||||
public bool yPlaneEnabled = true;
|
||||
public bool xPlaneEnabled = false;
|
||||
public bool zPlaneEnabled = false;
|
||||
public bool isYPlaneShowingPositionText = true;
|
||||
public float fixedTextSizeFactor = 0.1f;
|
||||
|
||||
public bool isYPlaneShowingPositionText;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
yPlaneEnabled = true;
|
||||
xPlaneEnabled = false;
|
||||
zPlaneEnabled = false;
|
||||
isYPlaneShowingPositionText = true;
|
||||
RefreshPlanes();
|
||||
}
|
||||
|
||||
public void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
|
||||
var container = inspector.GenerateContainer("Grid Controller");
|
||||
|
||||
//网格设置
|
||||
var gridSettings = container.GenerateSubcontainer(3);
|
||||
var yPlaneToggle =
|
||||
inspector.GenerateToggle(this, gridSettings, "Y Plane", nameof(yPlaneEnabled))
|
||||
.AddListenerFunction(RefreshPlanes);
|
||||
var xPlaneToggle =
|
||||
inspector.GenerateToggle(this, gridSettings, "X Plane", nameof(xPlaneEnabled))
|
||||
.AddListenerFunction(RefreshPlanes);
|
||||
var zPlaneToggle =
|
||||
inspector.GenerateToggle(this, gridSettings, "Z Plane", nameof(zPlaneEnabled))
|
||||
|
||||
inspector.GenerateToggle(this, gridSettings, "Y Plane (XZ)", nameof(yPlaneEnabled))
|
||||
.AddListenerFunction(RefreshPlanes);
|
||||
|
||||
var yPlaneShowPositionToggle =
|
||||
inspector.GenerateToggle(this, gridSettings, "Show Y Plane Position", nameof(isYPlaneShowingPositionText))
|
||||
.AddListenerFunction(RefreshPlanes);
|
||||
inspector.GenerateToggle(this, gridSettings, "X Plane (YZ)", nameof(xPlaneEnabled))
|
||||
.AddListenerFunction(RefreshPlanes);
|
||||
|
||||
inspector.GenerateToggle(this, gridSettings, "Z Plane (XY)", nameof(zPlaneEnabled))
|
||||
.AddListenerFunction(RefreshPlanes);
|
||||
|
||||
inspector.GenerateToggle(this, gridSettings, "Show Y Plane Pos", nameof(isYPlaneShowingPositionText))
|
||||
.AddListenerFunction(RefreshPlanes);
|
||||
inspector.GenerateInputField(this, gridSettings, "Fixed Text Size Factor", nameof(fixedTextSizeFactor))
|
||||
.AddListenerFunction(RefreshPlanes);
|
||||
}
|
||||
|
||||
private void RefreshPlanes()
|
||||
{
|
||||
yPlaneGrid.gameObject.SetActive(yPlaneEnabled);
|
||||
xPlaneGrid.gameObject.SetActive(xPlaneEnabled);
|
||||
zPlaneGrid.gameObject.SetActive(zPlaneEnabled);
|
||||
yPlaneGrid.isShowingPositionText = isYPlaneShowingPositionText;
|
||||
SetGridState(yPlaneGrid, yPlaneEnabled, isYPlaneShowingPositionText);
|
||||
SetGridState(xPlaneGrid, xPlaneEnabled, false); // 假设其他平面暂时不显示文字
|
||||
SetGridState(zPlaneGrid, zPlaneEnabled, false);
|
||||
}
|
||||
|
||||
if (!yPlaneGrid.isShowingPositionText)
|
||||
private void SetGridState(EditorGrid grid, bool active, bool showText)
|
||||
{
|
||||
if (grid == null) return;
|
||||
|
||||
grid.gameObject.SetActive(active);
|
||||
|
||||
if (active)
|
||||
{
|
||||
foreach (KeyValuePair<GameObject, Vector3> positionText in yPlaneGrid.positionTexts)
|
||||
{
|
||||
LeanPool.Despawn(positionText.Key);
|
||||
}
|
||||
grid.canShowPositionText = showText;
|
||||
grid.isShowingPositionText = showText;
|
||||
|
||||
yPlaneGrid.positionTexts.Clear();
|
||||
// 如果关闭了文字显示,立刻清理
|
||||
if (!showText)
|
||||
{
|
||||
grid.ClearAllTexts();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ MonoBehaviour:
|
||||
m_Name: SSAO
|
||||
m_EditorClassIdentifier:
|
||||
m_Active: 1
|
||||
m_Shader: {fileID: 0}
|
||||
m_Settings:
|
||||
AOMethod: 1
|
||||
Downsample: 1
|
||||
AfterOpaque: 0
|
||||
Source: 0
|
||||
@@ -22,7 +22,19 @@ MonoBehaviour:
|
||||
Intensity: 0.5
|
||||
DirectLightingStrength: 0.25
|
||||
Radius: 0.25
|
||||
SampleCount: 4
|
||||
Samples: 2
|
||||
BlurQuality: 0
|
||||
Falloff: 100
|
||||
SampleCount: -1
|
||||
m_BlueNoise256Textures:
|
||||
- {fileID: 2800000, guid: 36f118343fc974119bee3d09e2111500, type: 3}
|
||||
- {fileID: 2800000, guid: 4b7b083e6b6734e8bb2838b0b50a0bc8, type: 3}
|
||||
- {fileID: 2800000, guid: c06cc21c692f94f5fb5206247191eeee, type: 3}
|
||||
- {fileID: 2800000, guid: cb76dd40fa7654f9587f6a344f125c9a, type: 3}
|
||||
- {fileID: 2800000, guid: e32226222ff144b24bf3a5a451de54bc, type: 3}
|
||||
- {fileID: 2800000, guid: 3302065f671a8450b82c9ddf07426f3a, type: 3}
|
||||
- {fileID: 2800000, guid: 56a77a3e8d64f47b6afe9e3c95cb57d5, type: 3}
|
||||
m_Shader: {fileID: 4800000, guid: 0849e84e3d62649e8882e9d6f056a017, type: 3}
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -38,11 +50,13 @@ MonoBehaviour:
|
||||
debugShaders:
|
||||
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7,
|
||||
type: 3}
|
||||
hdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3}
|
||||
m_RendererFeatures:
|
||||
- {fileID: -1878332245247344467}
|
||||
m_RendererFeatureMap: adc0de57c6d2eee5
|
||||
m_UseNativeRenderPass: 0
|
||||
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
|
||||
xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2}
|
||||
shaders:
|
||||
blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3}
|
||||
copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
|
||||
@@ -50,11 +64,25 @@ MonoBehaviour:
|
||||
samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
|
||||
stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
|
||||
fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
|
||||
fallbackLoadingPS: {fileID: 4800000, guid: 7f888aff2ac86494babad1c2c5daeee2, type: 3}
|
||||
materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3}
|
||||
coreBlitPS: {fileID: 0}
|
||||
coreBlitColorAndDepthPS: {fileID: 0}
|
||||
cameraMotionVector: {fileID: 0}
|
||||
objectMotionVector: {fileID: 0}
|
||||
coreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3}
|
||||
coreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b,
|
||||
type: 3}
|
||||
blitHDROverlay: {fileID: 4800000, guid: a89bee29cffa951418fc1e2da94d1959, type: 3}
|
||||
cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf,
|
||||
type: 3}
|
||||
objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486,
|
||||
type: 3}
|
||||
dataDrivenLensFlare: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92,
|
||||
type: 3}
|
||||
terrainDetailLitPS: {fileID: 4800000, guid: f6783ab646d374f94b199774402a5144,
|
||||
type: 3}
|
||||
terrainDetailGrassPS: {fileID: 4800000, guid: e507fdfead5ca47e8b9a768b51c291a1,
|
||||
type: 3}
|
||||
terrainDetailGrassBillboardPS: {fileID: 4800000, guid: 29868e73b638e48ca99a19ea58c48d90,
|
||||
type: 3}
|
||||
m_AssetVersion: 2
|
||||
m_OpaqueLayerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
@@ -68,9 +96,9 @@ MonoBehaviour:
|
||||
passOperation: 2
|
||||
failOperation: 0
|
||||
zFailOperation: 0
|
||||
m_ShadowTransparentReceive: 1
|
||||
m_ShadowTransparentReceive: 0
|
||||
m_RenderingMode: 0
|
||||
m_DepthPrimingMode: 0
|
||||
m_CopyDepthMode: 0
|
||||
m_AccurateGbufferNormals: 0
|
||||
m_ClusteredRendering: 0
|
||||
m_TileSize: 32
|
||||
m_IntermediateTextureMode: 1
|
||||
|
||||
@@ -33,10 +33,10 @@ MonoBehaviour:
|
||||
m_EnableLODCrossFade: 1
|
||||
m_LODCrossFadeDitheringType: 1
|
||||
m_ShEvalMode: 0
|
||||
m_MainLightRenderingMode: 1
|
||||
m_MainLightRenderingMode: 0
|
||||
m_MainLightShadowsSupported: 1
|
||||
m_MainLightShadowmapResolution: 1024
|
||||
m_AdditionalLightsRenderingMode: 1
|
||||
m_AdditionalLightsRenderingMode: 0
|
||||
m_AdditionalLightsPerObjectLimit: 2
|
||||
m_AdditionalLightShadowsSupported: 0
|
||||
m_AdditionalLightsShadowmapResolution: 512
|
||||
|
||||
@@ -68,8 +68,8 @@ MonoBehaviour:
|
||||
m_Active: 0
|
||||
settings:
|
||||
pixelateShader: {fileID: 4800000, guid: 272e7eef87baea8408e583d2670e66dd, type: 3}
|
||||
pixelateStrengthX: 1366
|
||||
pixelateStrengthY: 768
|
||||
pixelateStrengthX: 1377
|
||||
pixelateStrengthY: 767
|
||||
passEvent: 500
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
@@ -115,6 +115,12 @@ MonoBehaviour:
|
||||
type: 3}
|
||||
dataDrivenLensFlare: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92,
|
||||
type: 3}
|
||||
terrainDetailLitPS: {fileID: 4800000, guid: f6783ab646d374f94b199774402a5144,
|
||||
type: 3}
|
||||
terrainDetailGrassPS: {fileID: 4800000, guid: e507fdfead5ca47e8b9a768b51c291a1,
|
||||
type: 3}
|
||||
terrainDetailGrassBillboardPS: {fileID: 4800000, guid: 29868e73b638e48ca99a19ea58c48d90,
|
||||
type: 3}
|
||||
m_AssetVersion: 2
|
||||
m_OpaqueLayerMask:
|
||||
serializedVersion: 2
|
||||
@@ -129,7 +135,7 @@ MonoBehaviour:
|
||||
passOperation: 2
|
||||
failOperation: 0
|
||||
zFailOperation: 0
|
||||
m_ShadowTransparentReceive: 1
|
||||
m_ShadowTransparentReceive: 0
|
||||
m_RenderingMode: 2
|
||||
m_DepthPrimingMode: 1
|
||||
m_CopyDepthMode: 0
|
||||
|
||||
@@ -25,7 +25,7 @@ MonoBehaviour:
|
||||
m_SupportsTerrainHoles: 1
|
||||
m_SupportsHDR: 1
|
||||
m_HDRColorBufferPrecision: 0
|
||||
m_MSAA: 4
|
||||
m_MSAA: 1
|
||||
m_RenderScale: 1
|
||||
m_UpscalingFilter: 0
|
||||
m_FsrOverrideSharpness: 0
|
||||
@@ -33,28 +33,28 @@ MonoBehaviour:
|
||||
m_EnableLODCrossFade: 1
|
||||
m_LODCrossFadeDitheringType: 1
|
||||
m_ShEvalMode: 0
|
||||
m_MainLightRenderingMode: 1
|
||||
m_MainLightShadowsSupported: 1
|
||||
m_MainLightRenderingMode: 0
|
||||
m_MainLightShadowsSupported: 0
|
||||
m_MainLightShadowmapResolution: 4096
|
||||
m_AdditionalLightsRenderingMode: 1
|
||||
m_AdditionalLightsRenderingMode: 0
|
||||
m_AdditionalLightsPerObjectLimit: 8
|
||||
m_AdditionalLightShadowsSupported: 1
|
||||
m_AdditionalLightShadowsSupported: 0
|
||||
m_AdditionalLightsShadowmapResolution: 4096
|
||||
m_AdditionalLightsShadowResolutionTierLow: 128
|
||||
m_AdditionalLightsShadowResolutionTierMedium: 256
|
||||
m_AdditionalLightsShadowResolutionTierHigh: 512
|
||||
m_ReflectionProbeBlending: 1
|
||||
m_ReflectionProbeBoxProjection: 1
|
||||
m_ShadowDistance: 150
|
||||
m_ReflectionProbeBlending: 0
|
||||
m_ReflectionProbeBoxProjection: 0
|
||||
m_ShadowDistance: 0
|
||||
m_ShadowCascadeCount: 4
|
||||
m_Cascade2Split: 0.25
|
||||
m_Cascade3Split: {x: 0.1, y: 0.3}
|
||||
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
|
||||
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.46015096}
|
||||
m_CascadeBorder: 0.1
|
||||
m_ShadowDepthBias: 1
|
||||
m_ShadowNormalBias: 1
|
||||
m_AnyShadowsSupported: 1
|
||||
m_SoftShadowsSupported: 1
|
||||
m_SoftShadowsSupported: 0
|
||||
m_ConservativeEnclosingSphere: 0
|
||||
m_NumIterationsEnclosingSphere: 64
|
||||
m_SoftShadowQuality: 2
|
||||
|
||||
@@ -15,10 +15,12 @@ MonoBehaviour:
|
||||
debugShaders:
|
||||
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7,
|
||||
type: 3}
|
||||
hdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3}
|
||||
m_RendererFeatures: []
|
||||
m_RendererFeatureMap:
|
||||
m_UseNativeRenderPass: 0
|
||||
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
|
||||
xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2}
|
||||
shaders:
|
||||
blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3}
|
||||
copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
|
||||
@@ -26,11 +28,25 @@ MonoBehaviour:
|
||||
samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
|
||||
stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
|
||||
fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
|
||||
fallbackLoadingPS: {fileID: 4800000, guid: 7f888aff2ac86494babad1c2c5daeee2, type: 3}
|
||||
materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3}
|
||||
coreBlitPS: {fileID: 0}
|
||||
coreBlitColorAndDepthPS: {fileID: 0}
|
||||
cameraMotionVector: {fileID: 0}
|
||||
objectMotionVector: {fileID: 0}
|
||||
coreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3}
|
||||
coreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b,
|
||||
type: 3}
|
||||
blitHDROverlay: {fileID: 4800000, guid: a89bee29cffa951418fc1e2da94d1959, type: 3}
|
||||
cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf,
|
||||
type: 3}
|
||||
objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486,
|
||||
type: 3}
|
||||
dataDrivenLensFlare: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92,
|
||||
type: 3}
|
||||
terrainDetailLitPS: {fileID: 4800000, guid: f6783ab646d374f94b199774402a5144,
|
||||
type: 3}
|
||||
terrainDetailGrassPS: {fileID: 4800000, guid: e507fdfead5ca47e8b9a768b51c291a1,
|
||||
type: 3}
|
||||
terrainDetailGrassBillboardPS: {fileID: 4800000, guid: 29868e73b638e48ca99a19ea58c48d90,
|
||||
type: 3}
|
||||
m_AssetVersion: 2
|
||||
m_OpaqueLayerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
@@ -44,9 +60,9 @@ MonoBehaviour:
|
||||
passOperation: 2
|
||||
failOperation: 0
|
||||
zFailOperation: 0
|
||||
m_ShadowTransparentReceive: 1
|
||||
m_ShadowTransparentReceive: 0
|
||||
m_RenderingMode: 0
|
||||
m_DepthPrimingMode: 0
|
||||
m_CopyDepthMode: 0
|
||||
m_AccurateGbufferNormals: 0
|
||||
m_ClusteredRendering: 0
|
||||
m_TileSize: 32
|
||||
m_IntermediateTextureMode: 1
|
||||
|
||||
@@ -253,22 +253,10 @@
|
||||
"animationCurveType" : 1
|
||||
},{
|
||||
"startValue" : 12,
|
||||
"endValue" : 3,
|
||||
"endValue" : 0,
|
||||
"startTime" : 6,
|
||||
"endTime" : 6.6,
|
||||
"animationCurveType" : 1
|
||||
},{
|
||||
"startValue" : 3,
|
||||
"endValue" : 0,
|
||||
"startTime" : 7.2,
|
||||
"endTime" : 7.8,
|
||||
"animationCurveType" : 1
|
||||
},{
|
||||
"startValue" : 0,
|
||||
"endValue" : 2,
|
||||
"startTime" : 8.400001,
|
||||
"endTime" : 9.000001,
|
||||
"animationCurveType" : 1
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1143,19 +1131,7 @@
|
||||
"startValue" : 1,
|
||||
"endValue" : 2,
|
||||
"startTime" : 1,
|
||||
"endTime" : 4.8,
|
||||
"animationCurveType" : 0
|
||||
},{
|
||||
"startValue" : 2,
|
||||
"endValue" : 0,
|
||||
"startTime" : 5.4,
|
||||
"endTime" : 6,
|
||||
"animationCurveType" : 0
|
||||
},{
|
||||
"startValue" : 0,
|
||||
"endValue" : 0,
|
||||
"startTime" : 6,
|
||||
"endTime" : 6.6,
|
||||
"endTime" : 10.8,
|
||||
"animationCurveType" : 0
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1106,6 +1106,65 @@
|
||||
"attachedElementGuid" : {
|
||||
"value" : "ede46dfd-b718-4e33-8838-060bee61514b"
|
||||
}
|
||||
},{
|
||||
"__type" : "Ichni.RhythmGame.Beatmap.Displacement_BM,Assembly-CSharp",
|
||||
"positionX" : {
|
||||
"animatedFloatList" : [
|
||||
{
|
||||
"startValue" : 0,
|
||||
"endValue" : 0,
|
||||
"startTime" : 0,
|
||||
"endTime" : 1,
|
||||
"animationCurveType" : 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"positionY" : {
|
||||
"animatedFloatList" : [
|
||||
{
|
||||
"startValue" : 0,
|
||||
"endValue" : 0,
|
||||
"startTime" : 0,
|
||||
"endTime" : 1,
|
||||
"animationCurveType" : 0
|
||||
},{
|
||||
"startValue" : 1,
|
||||
"endValue" : 2,
|
||||
"startTime" : 1,
|
||||
"endTime" : 10.8,
|
||||
"animationCurveType" : 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"positionZ" : {
|
||||
"animatedFloatList" : [
|
||||
{
|
||||
"startValue" : 0,
|
||||
"endValue" : 0,
|
||||
"startTime" : 0,
|
||||
"endTime" : 1,
|
||||
"animationCurveType" : 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"elementName" : "New Displacement",
|
||||
"tags" : [
|
||||
|
||||
],
|
||||
"elementGuid" : {
|
||||
"value" : "95a2a15b-5f34-48f4-8be4-569fd41fc9cd"
|
||||
},
|
||||
"attachedElementGuid" : {
|
||||
"value" : "11fa6295-76d4-4969-8ca0-30e05484f7da"
|
||||
}
|
||||
},{
|
||||
"__type" : "Ichni.RhythmGame.Beatmap.TimeDurationSubmodule_BM,Assembly-CSharp",
|
||||
"isOverridingDuration" : false,
|
||||
"startTime" : -32767,
|
||||
"endTime" : 32767,
|
||||
"attachedElementGuid" : {
|
||||
"value" : "95a2a15b-5f34-48f4-8be4-569fd41fc9cd"
|
||||
}
|
||||
}
|
||||
],
|
||||
"attachedElementGuid" : {
|
||||
|
||||
7
Assets/StreamingAssets/AutoSave/Pof/AutoSave_1.json.meta
Normal file
7
Assets/StreamingAssets/AutoSave/Pof/AutoSave_1.json.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0689d8603a82dc64cabaa3605562fb6d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
7
Assets/StreamingAssets/AutoSave/Pof/AutoSave_2.json.meta
Normal file
7
Assets/StreamingAssets/AutoSave/Pof/AutoSave_2.json.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60f4ce4f747b8f04eadd71f0cde6f9cb
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
ManifestFileVersion: 0
|
||||
CRC: 1294045812
|
||||
CRC: 1386194157
|
||||
AssetBundleManifest:
|
||||
AssetBundleInfos:
|
||||
Info_0:
|
||||
|
||||
Binary file not shown.
@@ -1,15 +1,15 @@
|
||||
ManifestFileVersion: 0
|
||||
CRC: 79112673
|
||||
CRC: 3340848061
|
||||
Hashes:
|
||||
AssetFileHash:
|
||||
serializedVersion: 2
|
||||
Hash: 23cba9f25db129175042bf17b9252c74
|
||||
Hash: 6ff2071f1a0d2fac7786b8a1f4f0c641
|
||||
TypeTreeHash:
|
||||
serializedVersion: 2
|
||||
Hash: 6800a16f3e87d1e6002804cd7e7d1484
|
||||
IncrementalBuildHash:
|
||||
serializedVersion: 2
|
||||
Hash: 23cba9f25db129175042bf17b9252c74
|
||||
Hash: 6ff2071f1a0d2fac7786b8a1f4f0c641
|
||||
HashAppended: 0
|
||||
ClassTypes:
|
||||
- Class: 1
|
||||
|
||||
Binary file not shown.
@@ -1,15 +1,15 @@
|
||||
ManifestFileVersion: 0
|
||||
CRC: 2962700494
|
||||
CRC: 730802483
|
||||
Hashes:
|
||||
AssetFileHash:
|
||||
serializedVersion: 2
|
||||
Hash: 6831c39e98efccc83621852c43663a9a
|
||||
Hash: 19b773f7bd46a1c2faba5b4b05a89c95
|
||||
TypeTreeHash:
|
||||
serializedVersion: 2
|
||||
Hash: 5f75b1d159db4349b37b25336eb07c68
|
||||
IncrementalBuildHash:
|
||||
serializedVersion: 2
|
||||
Hash: 6831c39e98efccc83621852c43663a9a
|
||||
Hash: 19b773f7bd46a1c2faba5b4b05a89c95
|
||||
HashAppended: 0
|
||||
ClassTypes:
|
||||
- Class: 1
|
||||
|
||||
142
Assets/ThemeBundles/Basic/Materials/PseudoShadow.mat
Normal file
142
Assets/ThemeBundles/Basic/Materials/PseudoShadow.mat
Normal file
@@ -0,0 +1,142 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: PseudoShadow
|
||||
m_Shader: {fileID: 4800000, guid: b0be33a199aeb024c9b95c50aca88655, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- USE_RIM
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 1
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 3000
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: 5392668a037c8bf49b4479948ee1f3fd, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 0
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 0
|
||||
- _Metallic: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.005
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _RimPower: 3
|
||||
- _ShadowSmoothness: 0.74
|
||||
- _ShadowStrength: 1
|
||||
- _ShadowThreshold: 0.11
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UseRim: 1
|
||||
- _UseWorldLight: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color: {r: 0.6698113, g: 0.609781, b: 0.609781, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _FakeLightDir: {r: 0.23, g: 0.24, b: 0.24, a: 0}
|
||||
- _RimColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _ShadowColor: {r: 0.22961909, g: 0.22961909, b: 0.299, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!114 &1391350818744910211
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 7
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dec78779f3858d84cbe78f2addd7d2ce
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
115
Assets/ThemeBundles/Basic/Materials/PseudoShadow.shader
Normal file
115
Assets/ThemeBundles/Basic/Materials/PseudoShadow.shader
Normal file
@@ -0,0 +1,115 @@
|
||||
Shader "Custom/ImprovedPseudoShadow" {
|
||||
Properties {
|
||||
[Header(Base)]
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_Color ("Main Color", Color) = (1,1,1,1)
|
||||
|
||||
[Header(Shadow)]
|
||||
_ShadowColor ("Shadow Color", Color) = (0.2, 0.2, 0.3, 1) // 默认偏蓝的阴影
|
||||
_ShadowThreshold ("Shadow Threshold", Range(-1,1)) = 0.0
|
||||
_ShadowSmoothness ("Shadow Smoothness", Range(0,1)) = 0.1
|
||||
|
||||
[Header(Lighting Mode)]
|
||||
[Toggle(USE_WORLD_LIGHT)] _UseWorldLight ("Use Fixed World Light?", Float) = 0
|
||||
_FakeLightDir ("Fake Light Dir (XYZ)", Vector) = (0.5, 1, 0.5, 0) // 模拟从右上方来的光
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="Transparent" }
|
||||
LOD 100
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
// 开启 GPU Instancing 支持
|
||||
#pragma multi_compile_instancing
|
||||
// 开启着色器变体以支持两种光照模式
|
||||
#pragma shader_feature USE_WORLD_LIGHT
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID // Instancing ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
float lightFactor : TEXCOORD1; // 传递光照因子
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID // Instancing ID
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
// 声明 Instancing 属性变量
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _Color)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _ShadowColor)
|
||||
UNITY_DEFINE_INSTANCED_PROP(float4, _FakeLightDir)
|
||||
UNITY_DEFINE_INSTANCED_PROP(float, _ShadowThreshold)
|
||||
UNITY_DEFINE_INSTANCED_PROP(float, _ShadowSmoothness)
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(o, v);
|
||||
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
|
||||
float3 normalWorld = UnityObjectToWorldNormal(v.normal);
|
||||
float3 lightDir;
|
||||
|
||||
#ifdef USE_WORLD_LIGHT
|
||||
// 改进1:使用固定的世界空间伪光照方向
|
||||
lightDir = normalize(UNITY_ACCESS_INSTANCED_PROP(Props, _FakeLightDir).xyz);
|
||||
#else
|
||||
// 原版逻辑:使用视线方向 (Headlamp)
|
||||
// 注意:为了获得类似漫反射的效果,这里通常不需要取反,
|
||||
// 但如果要模拟“边缘光”则算法不同。这里沿用原文档的思路:面朝相机越亮。
|
||||
lightDir = normalize(WorldSpaceViewDir(v.vertex));
|
||||
#endif
|
||||
|
||||
// 点积计算 (-1 到 1)
|
||||
float dotProduct = dot(normalWorld, lightDir);
|
||||
|
||||
// 将点积结果保存,在片元阶段处理颜色,或者直接在这里计算
|
||||
// 保持 Vertex Lighting 的高性能
|
||||
o.lightFactor = dotProduct;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target {
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
|
||||
// 获取属性
|
||||
fixed4 mainColor = UNITY_ACCESS_INSTANCED_PROP(Props, _Color);
|
||||
fixed4 shadowColor = UNITY_ACCESS_INSTANCED_PROP(Props, _ShadowColor);
|
||||
float threshold = UNITY_ACCESS_INSTANCED_PROP(Props, _ShadowThreshold);
|
||||
float smoothness = UNITY_ACCESS_INSTANCED_PROP(Props, _ShadowSmoothness);
|
||||
|
||||
fixed4 texCol = tex2D(_MainTex, i.uv) * mainColor;
|
||||
|
||||
// 改进2:更平滑且可控的阈值计算 (Smoothstep)
|
||||
// lightFactor 越大说明越直接面对光源
|
||||
float lightIntensity = smoothstep(threshold, threshold + smoothness, i.lightFactor);
|
||||
|
||||
// 改进3:基于光照强度的颜色插值 (Lerp)
|
||||
// 0 (背光) -> ShadowColor
|
||||
// 1 (受光) -> Texture Color
|
||||
fixed3 finalRGB = lerp(shadowColor.rgb * texCol.rgb, texCol.rgb, lightIntensity);
|
||||
|
||||
return fixed4(finalRGB, texCol.a);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "VertexLit"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0be33a199aeb024c9b95c50aca88655
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -62,7 +62,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
|
||||
- {fileID: 2100000, guid: dec78779f3858d84cbe78f2addd7d2ce, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -121,6 +121,9 @@ MonoBehaviour:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: enableTypes
|
||||
Entry: 6
|
||||
Data:
|
||||
elementName:
|
||||
tags: []
|
||||
parentElement: {fileID: 0}
|
||||
|
||||
@@ -62,7 +62,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
|
||||
- {fileID: 2100000, guid: dec78779f3858d84cbe78f2addd7d2ce, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -121,6 +121,9 @@ MonoBehaviour:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: enableTypes
|
||||
Entry: 6
|
||||
Data:
|
||||
elementName:
|
||||
tags: []
|
||||
parentElement: {fileID: 0}
|
||||
|
||||
@@ -62,7 +62,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
|
||||
- {fileID: 2100000, guid: dec78779f3858d84cbe78f2addd7d2ce, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -121,6 +121,9 @@ MonoBehaviour:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: enableTypes
|
||||
Entry: 6
|
||||
Data:
|
||||
elementName:
|
||||
tags: []
|
||||
parentElement: {fileID: 0}
|
||||
|
||||
@@ -62,7 +62,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
|
||||
- {fileID: 2100000, guid: dec78779f3858d84cbe78f2addd7d2ce, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -121,6 +121,9 @@ MonoBehaviour:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: enableTypes
|
||||
Entry: 6
|
||||
Data:
|
||||
elementName:
|
||||
tags: []
|
||||
parentElement: {fileID: 0}
|
||||
|
||||
@@ -62,7 +62,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
|
||||
- {fileID: 2100000, guid: dec78779f3858d84cbe78f2addd7d2ce, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -121,6 +121,9 @@ MonoBehaviour:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: enableTypes
|
||||
Entry: 6
|
||||
Data:
|
||||
elementName:
|
||||
tags: []
|
||||
parentElement: {fileID: 0}
|
||||
|
||||
@@ -122,10 +122,10 @@ QualitySettings:
|
||||
globalTextureMipmapLimit: 0
|
||||
textureMipmapLimitSettings: []
|
||||
anisotropicTextures: 2
|
||||
antiAliasing: 4
|
||||
antiAliasing: 0
|
||||
softParticles: 0
|
||||
softVegetation: 1
|
||||
realtimeReflectionProbes: 1
|
||||
realtimeReflectionProbes: 0
|
||||
billboardsFaceCameraPosition: 1
|
||||
useLegacyDetailDistribution: 1
|
||||
vSyncCount: 0
|
||||
|
||||
Reference in New Issue
Block a user