something & 编辑器指南
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.Mathematics;
|
||||
using Ichni.Editor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
@@ -20,7 +18,18 @@ namespace Ichni.RhythmGame
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||||
|
||||
}
|
||||
public override void Initialize(string name, Guid elementGuid, List<string> tags,
|
||||
bool isFirstGenerated, GameElement parentElement)
|
||||
{
|
||||
base.Initialize(name, elementGuid, tags, isFirstGenerated, parentElement);
|
||||
if (this.parentElement.submoduleList.Where(e => e is TransformSubmodule).Count() == 0)
|
||||
{
|
||||
LogWindow.Log("AnimationBase must be attached to a GameElement with TransformSubmodule", Color.red);
|
||||
//OnDelete();
|
||||
//return;
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新动画
|
||||
/// </summary>
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public List<GameElement> gameElementList;
|
||||
public BaseElement_BM matchedBM { get; set; }
|
||||
|
||||
|
||||
public BeatmapContainer()
|
||||
{
|
||||
gameElementList = new List<GameElement>();
|
||||
gameElementList = new List<GameElement>();
|
||||
}
|
||||
|
||||
|
||||
public void SaveBM()
|
||||
{
|
||||
matchedBM = new BeatmapContainer_BM(gameElementList);
|
||||
@@ -25,7 +25,7 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
@@ -40,17 +40,17 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public BeatmapContainer_BM()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public BeatmapContainer_BM(List<GameElement> gameElementList)
|
||||
{
|
||||
elementList = new List<BaseElement_BM>();
|
||||
|
||||
|
||||
gameElementList.ForEach(e =>
|
||||
{
|
||||
e.SaveBM();
|
||||
e.submoduleList.RemoveAll(s=>s == null);
|
||||
e.submoduleList.RemoveAll(s => s == null);
|
||||
e.submoduleList.ForEach(s => s.SaveBM());
|
||||
});
|
||||
|
||||
@@ -67,11 +67,20 @@ namespace Ichni.RhythmGame
|
||||
|
||||
elementList.ForEach(element =>
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
Debug.LogError("Null element detected in elementList. Skipping execution.");
|
||||
return;
|
||||
}
|
||||
Debug.Log(element.GetType());
|
||||
if (LowLoadPriorityTypes.Contains(element.GetType()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (element is GameElement_BM gameElement)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
@@ -79,12 +88,18 @@ namespace Ichni.RhythmGame
|
||||
#endif
|
||||
GameElement_BM.identifier.Add(gameElement.elementGuid, gameElement);
|
||||
}
|
||||
|
||||
|
||||
element.ExecuteBM();
|
||||
});
|
||||
|
||||
elementList.ForEach(element =>
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
Debug.LogError("Null element detected in elementList during low-priority execution. Skipping execution.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (LowLoadPriorityTypes.Contains(element.GetType()))
|
||||
{
|
||||
element.ExecuteBM();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
@@ -36,17 +37,17 @@ namespace Ichni.RhythmGame
|
||||
LogWindow.Log("Only one GameCamera can be created", Color.red);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
GameCamera gameCamera =
|
||||
Instantiate(EditorManager.instance.basePrefabs.gameCamera).GetComponent<GameCamera>();
|
||||
|
||||
gameCamera.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
|
||||
|
||||
|
||||
cameraManager.gameCamera = gameCamera;
|
||||
cameraManager.backgroundCamera.GetComponent<UniversalAdditionalCameraData>().cameraStack.Add(gameCamera.camera);
|
||||
if (cameraManager.isSceneCameraActive) gameCamera.camera.enabled = false;
|
||||
|
||||
|
||||
|
||||
|
||||
gameCamera.parentElement = parentElement;
|
||||
gameCamera.cameraViewType = cameraViewType;
|
||||
gameCamera.camera.orthographic = cameraViewType == CameraViewType.Orthographic;
|
||||
@@ -74,13 +75,29 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public partial class GameCamera
|
||||
{
|
||||
private Vector3 GetWorldEulerAngles()
|
||||
{
|
||||
Vector3 output = transformSubmodule.originalEulerAngles;
|
||||
GameElement element = this;
|
||||
while (element != null)
|
||||
{
|
||||
if (element is IHaveTransformSubmodule)
|
||||
{
|
||||
output += ((TransformSubmodule)element.submoduleList.Where(r => r is TransformSubmodule).First()).currentEulerAngles;
|
||||
}
|
||||
element = element.parentElement;
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
public void SetTransformObserver()
|
||||
{
|
||||
Observable.EveryUpdate().Subscribe(_ =>
|
||||
{
|
||||
if (transformSubmodule.eulerAnglesOffsetLock)
|
||||
{
|
||||
rotationPoint.eulerAngles = transformSubmodule.currentEulerAngles;
|
||||
rotationPoint.localEulerAngles = transformSubmodule.originalEulerAngles;
|
||||
}
|
||||
else if (transformSubmodule.eulerAnglesDirtyMark)
|
||||
{
|
||||
@@ -91,7 +108,7 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
|
||||
transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + offset;
|
||||
rotationPoint.eulerAngles = transformSubmodule.currentEulerAngles;
|
||||
rotationPoint.localEulerAngles = transformSubmodule.currentEulerAngles;
|
||||
transformSubmodule.eulerAnglesDirtyMark = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Ichni.Editor
|
||||
{
|
||||
[Tooltip("指定用于计算缩放的摄像机(若为空则使用 Camera.main)")]
|
||||
public Camera sceneCamera;
|
||||
|
||||
|
||||
public float cameraDistance;
|
||||
|
||||
[Tooltip("指定网格所在的平面:0 = XZ (y=0), 1 = XY (z=0), 2 = YZ (x=0)")]
|
||||
@@ -41,7 +41,7 @@ namespace Ichni.Editor
|
||||
void Start()
|
||||
{
|
||||
positionTexts = new Dictionary<GameObject, Vector3>();
|
||||
|
||||
|
||||
sceneCamera = EditorManager.instance.cameraManager.sceneCamera.sceneCamera;
|
||||
// 实例化材质,避免修改共享材质
|
||||
gridMaterial = GetComponent<MeshRenderer>().material;
|
||||
@@ -52,7 +52,7 @@ namespace Ichni.Editor
|
||||
void Update()
|
||||
{
|
||||
sceneCamera = EditorManager.instance.cameraManager.currentCamera;
|
||||
|
||||
|
||||
// 计算摄像机到网格平面的垂直距离
|
||||
cameraDistance = 0f;
|
||||
Vector3 camPos = sceneCamera.transform.position;
|
||||
@@ -76,12 +76,12 @@ namespace Ichni.Editor
|
||||
|
||||
gridMaterial.SetFloat("_GridScale", 1 / gridScale);
|
||||
gridMaterial.SetFloat("_DisappearEndDistance", 100 * gridScale);
|
||||
|
||||
|
||||
if (canShowPositionText && isShowingPositionText)
|
||||
{
|
||||
GetPoints();
|
||||
|
||||
foreach (KeyValuePair<GameObject,Vector3> positionText in positionTexts)
|
||||
foreach (KeyValuePair<GameObject, Vector3> positionText in positionTexts)
|
||||
{
|
||||
positionText.Key.transform.position = positionText.Value + new Vector3(gridScale / 6, 0, gridScale / 12);
|
||||
float scaleFactor = gridScale * 1.5f;
|
||||
@@ -98,6 +98,7 @@ namespace Ichni.Editor
|
||||
if (sceneCameraHit.collider.gameObject == gameObject)
|
||||
{
|
||||
Vector3 point = sceneCameraHit.point;
|
||||
|
||||
float radius = gridScale * 16f;
|
||||
float step = gridScale * 4f;
|
||||
|
||||
@@ -114,13 +115,16 @@ namespace Ichni.Editor
|
||||
|
||||
List<Vector3> newPositions = new List<Vector3>();
|
||||
|
||||
// 添加距离检测逻辑
|
||||
bool withinDistance = Vector3.Distance(sceneCamera.transform.position, point) <= 100f;
|
||||
|
||||
for (float x = minX; x <= maxX; x += step)
|
||||
{
|
||||
for (float z = minZ; z <= maxZ; z += step)
|
||||
{
|
||||
Vector3 position = new Vector3(x, 0, z);
|
||||
|
||||
if (!positionTexts.ContainsValue(position))
|
||||
if (withinDistance && !positionTexts.ContainsValue(position))
|
||||
{
|
||||
GameObject posText = LeanPool.Spawn(positionTextPrefab);
|
||||
posText.transform.position = position + new Vector3(gridScale / 8, 0, gridScale / 16);
|
||||
@@ -133,7 +137,7 @@ namespace Ichni.Editor
|
||||
newPositions.Add(new Vector3(x, 0, z));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<GameObject> toRemove = new List<GameObject>();
|
||||
// 清除不在新范围内的Text
|
||||
foreach (KeyValuePair<GameObject, Vector3> positionText in positionTexts)
|
||||
@@ -144,7 +148,7 @@ namespace Ichni.Editor
|
||||
toRemove.Add(positionText.Key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach (GameObject text in toRemove)
|
||||
{
|
||||
positionTexts.Remove(text);
|
||||
|
||||
Reference in New Issue
Block a user