diff --git a/Assets/Prefabs/FixSystemPrefabs/CutLine.prefab b/Assets/Prefabs/FixSystemPrefabs/CutLine.prefab index 9aa7589a0..7847bcbc0 100644 --- a/Assets/Prefabs/FixSystemPrefabs/CutLine.prefab +++ b/Assets/Prefabs/FixSystemPrefabs/CutLine.prefab @@ -27,7 +27,7 @@ Transform: m_GameObject: {fileID: 5940362540916563197} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 3.1454616, y: -1.0817454, z: -0.80590516} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -80,7 +80,7 @@ LineRenderer: - {x: 0, y: 0, z: 1} m_Parameters: serializedVersion: 3 - widthMultiplier: 0.5 + widthMultiplier: 0.05 widthCurve: serializedVersion: 2 m_Curve: @@ -136,7 +136,7 @@ LineRenderer: m_MaskInteraction: 0 m_UseWorldSpace: 1 m_Loop: 1 - m_ApplyActiveColorSpace: 1 + m_ApplyActiveColorSpace: 0 --- !u!114 &5800310329352418143 MonoBehaviour: m_ObjectHideFlags: 0 @@ -149,5 +149,3 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5842a5c9314449c8a972472b796da927, type: 3} m_Name: m_EditorClassIdentifier: - lineRenderer: {fileID: 0} - clickRadius: 0.5 diff --git a/Assets/Scenes/StandardFixScene.unity b/Assets/Scenes/StandardFixScene.unity index de86e0bcf..8f034f679 100644 --- a/Assets/Scenes/StandardFixScene.unity +++ b/Assets/Scenes/StandardFixScene.unity @@ -279,6 +279,90 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!1 &50965008 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 50965009} + - component: {fileID: 50965010} + m_Layer: 0 + m_Name: Circle + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &50965009 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 50965008} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -11, y: 0.81, z: 0} + m_LocalScale: {x: 0.4, y: 0.4, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1610923217} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &50965010 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 50965008} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 1986402817 + m_SortingLayer: 19 + m_SortingOrder: 0 + m_Sprite: {fileID: -2413806693520163455, guid: a86470a33a6bf42c4b3595704624658b, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 --- !u!1 &70700667 GameObject: m_ObjectHideFlags: 0 @@ -5334,7 +5418,7 @@ MonoBehaviour: socketPos: {fileID: 0} data: moduleName: Memory - clickRadius: 0.5 + clickRadius: 0.2 --- !u!1 &706512415 GameObject: m_ObjectHideFlags: 0 @@ -11688,6 +11772,11 @@ MonoBehaviour: m_EditorClassIdentifier: taskTextPrefab: {fileID: 5295477770541402281, guid: ab166642babe53e4993fa1bd9bd57204, type: 3} taskListParent: {fileID: 1101482910} +--- !u!4 &1610923217 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 4256475766480134775, guid: 95188b5d2a557274fb52febde14400b8, type: 3} + m_PrefabInstance: {fileID: 7026926953013077400} + m_PrefabAsset: {fileID: 0} --- !u!1 &1612743779 GameObject: m_ObjectHideFlags: 0 @@ -16377,9 +16466,16 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 8890064519865571154, guid: 95188b5d2a557274fb52febde14400b8, type: 3} + propertyPath: cursor + value: + objectReference: {fileID: 50965010} m_RemovedComponents: [] m_RemovedGameObjects: [] - m_AddedGameObjects: [] + m_AddedGameObjects: + - targetCorrespondingSourceObject: {fileID: 4256475766480134775, guid: 95188b5d2a557274fb52febde14400b8, type: 3} + insertIndex: -1 + addedObject: {fileID: 50965009} m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 95188b5d2a557274fb52febde14400b8, type: 3} --- !u!1 &7169523939405871121 diff --git a/Assets/Scripts/FixSystemNew/BodyModule/BodyModule.cs b/Assets/Scripts/FixSystemNew/BodyModule/BodyModule.cs index 35b950953..521beee3b 100644 --- a/Assets/Scripts/FixSystemNew/BodyModule/BodyModule.cs +++ b/Assets/Scripts/FixSystemNew/BodyModule/BodyModule.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using AibisDream.Framework; using AibisDream.Utility; using Newtonsoft.Json; @@ -51,7 +52,7 @@ namespace AibisDream.FixSystem private void Update() { - if (_cutting && Input.GetMouseButtonDown(0)) + if (_cutting && Input.GetMouseButton(0)) { OnCut(); } @@ -114,6 +115,7 @@ namespace AibisDream.FixSystem { // 打开或获取CutLine ShowCutLine(); + _cutLine.OnCuttingDown += OnCuttingDown; _cutting = true; } @@ -123,6 +125,13 @@ namespace AibisDream.FixSystem _cutLine.DetectLineClick(mousePos, clickRadius); } + private void OnCuttingDown() + { + _cutLine.OnCuttingDown -= OnCuttingDown; + _cutting = false; + // TODO 播放切割动画 + } + private void ShowCutLine() { // 切割线不存在,就新建一个 @@ -132,7 +141,7 @@ namespace AibisDream.FixSystem var cutLineObj = Instantiate(prefab, transform); _cutLine = cutLineObj.GetComponent(); } - + // 对切割线进行初始化 var shapePoints = new List(); _targetSpriteRenderer.sprite.GetPhysicsShape(0, shapePoints); @@ -141,8 +150,13 @@ namespace AibisDream.FixSystem Debug.LogWarning($"{name} has no shape"); return; } - - _cutLine.Init(shapePoints, clickRadius); + + // 本地坐标转世界坐标 + var shapePointsV3 = shapePoints + .Select(item => _targetSpriteRenderer.transform.TransformPoint(item)) + .ToList(); + + _cutLine.Init(shapePointsV3, clickRadius); } #endregion diff --git a/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs b/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs index 6d6d7b30a..64ad2d68d 100644 --- a/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs +++ b/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs @@ -51,7 +51,7 @@ namespace AibisDream.FixSystem private void InitComponentRefs() { // 注册数据 - StorageSystem.Instance.RegisterData(_data); + // StorageSystem.Instance.RegisterData(_data); // 处理内部索引 _bodyModuleGroup = transform.Find("Body Module Group")?.gameObject; diff --git a/Assets/Scripts/FixSystemNew/BodyModule/CutLine.cs b/Assets/Scripts/FixSystemNew/BodyModule/CutLine.cs index 64a6f48f3..a08098081 100644 --- a/Assets/Scripts/FixSystemNew/BodyModule/CutLine.cs +++ b/Assets/Scripts/FixSystemNew/BodyModule/CutLine.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using UnityEngine; @@ -6,42 +7,97 @@ namespace AibisDream { public class CutLine : MonoBehaviour { + #region Shader参数 + + private static readonly int RangeCount = Shader.PropertyToID("_RangeCount"); + + #endregion + private LineRenderer _lineRenderer; + private Material _lineMaterial; private Vector2[] _linePoints; private float[] _normalizedLinePoints; + private float _totalLength; private Bounds _bounds; private List _recordedRanges = new(); + private static readonly int Ranges = Shader.PropertyToID("_Ranges"); + private static readonly int TotalLength = Shader.PropertyToID("_TotalLength"); + + public event Action OnCuttingDown; #region 初始化 - public void Init(List shapePoints, float clickRadius) + public void Init(List shapePoints, float clickRadius) { - _lineRenderer = GetComponent(); + if (!_lineRenderer) + { + _lineRenderer = GetComponent(); + _lineMaterial = _lineRenderer.materials[0]; + } - // 按照新点位重绘线条 - RedrawLine(shapePoints); + // 清除旧数据 + ClearOldData(); // 生成归一化点 NormalizePoints(shapePoints); + // 按照新点位重绘线条 + RedrawLine(shapePoints); // 生成基本的包围盒 GeneBoundingBox(clickRadius); - + ClearRecordedRanges(); } - private void RedrawLine(List shapePoints) + private void ClearOldData() { - var linePoints = shapePoints.Select(item => new Vector3(item.x, item.y, 0)).ToArray(); - _lineRenderer.SetPositions(linePoints); + _recordedRanges.Clear(); + _totalLength = 0; } - private void NormalizePoints(List shapePoints) + private void RedrawLine(List shapePoints) + { + // 画线 + var linePoints = shapePoints.ToArray(); + + _lineRenderer.positionCount = linePoints.Length; + _lineRenderer.SetPositions(linePoints); + // 设置Shader + _lineMaterial.SetFloat(TotalLength, _totalLength); + _lineMaterial.SetInt(RangeCount, 1); + _lineMaterial.SetVectorArray(Ranges, new List {Vector4.zero} ); + } + + private void UpdateMaterial() + { + if (_recordedRanges.Count <= 0) + { + return; + } + + // 将Range组装成Shader可以读取的格式 + var ranges = new List(); + + for (int i = 0; i < _recordedRanges.Count; i += 2) + { + var v1 = _recordedRanges[i]; + var v2 = i + 1 < _recordedRanges.Count ? _recordedRanges[i + 1] : Vector2.zero; + var combined = new Vector4(v1.x, v1.y, v2.x, v2.y); + ranges.Add(combined); + } + + // 更新线条 + _lineMaterial.SetInt(RangeCount, ranges.Count); + _lineMaterial.SetVectorArray(Ranges, ranges); + } + + private void NormalizePoints(List shapePoints) { // 先生成首尾相连的点,默认Loop shapePoints.Add(shapePoints[0]); - _linePoints = shapePoints.ToArray(); + _linePoints = shapePoints + .Select(item => new Vector2(item.x, item.y)) + .ToArray(); - float totalLength = 0f; var segmentLengths = new List(); // 计算总长度和各段长度 @@ -49,21 +105,23 @@ namespace AibisDream { var segmentLength = Vector2.Distance(_linePoints[i - 1], _linePoints[i]); segmentLengths.Add(segmentLength); - totalLength += segmentLength; + _totalLength += segmentLength; } // 计算每个点的归一化位置 var normalizedLinePoints = new float[segmentLengths.Count + 1]; normalizedLinePoints[0] = 0f; var accumulatedLength = 0f; - + for (var i = 0; i < segmentLengths.Count; i++) { accumulatedLength += segmentLengths[i]; - normalizedLinePoints[i + 1] = accumulatedLength / totalLength; + normalizedLinePoints[i + 1] = accumulatedLength / _totalLength; } + + _normalizedLinePoints = normalizedLinePoints; } - + private void GeneBoundingBox(float clickRadius) { _bounds = new Bounds(); @@ -71,14 +129,14 @@ namespace AibisDream { _bounds.Encapsulate(point); } - + _bounds.Expand(clickRadius * 2); } #endregion #region 切割检测 - + public void DetectLineClick(Vector2 clickPosition, float clickRadius) { // 先进行包围盒检测,不在包围盒直接返回 @@ -86,7 +144,7 @@ namespace AibisDream { return; } - + List newRanges = new List(); // 检查每条线段 @@ -95,24 +153,20 @@ namespace AibisDream Vector2 start = _linePoints[i - 1]; Vector2 end = _linePoints[i]; - // 计算点到线段的距离 - float distance = DistanceToSegment(clickPosition, start, end); - - if (distance <= clickRadius) + // 计算点覆盖线段的范围 + if (!TryGetCoverRange(start, end, clickPosition, clickRadius, out var rawRange)) { - // 计算点击影响的范围 - float normalizedStart = _normalizedLinePoints[i - 1]; - float normalizedEnd = _normalizedLinePoints[i]; - - // 计算实际影响的范围(考虑点击半径) - float segmentLength = Vector2.Distance(start, end); - float radiusRatio = clickRadius / segmentLength; - - float rangeStart = Mathf.Clamp01(normalizedStart - radiusRatio); - float rangeEnd = Mathf.Clamp01(normalizedEnd + radiusRatio); - - newRanges.Add(new Vector2(rangeStart, rangeEnd)); + // 如果未覆盖直接计算下一段 + continue; } + + // 将线段范围转成整体范围 + var normalizedStart = _normalizedLinePoints[i - 1]; + var normalizedEnd = _normalizedLinePoints[i]; + var normalizedDistance = normalizedEnd - normalizedStart; + + var range = rawRange * normalizedDistance + new Vector2(normalizedStart, normalizedStart); + newRanges.Add(range); } // 合并新检测到的区间 @@ -123,39 +177,76 @@ namespace AibisDream // 合并所有重叠区间 MergeRanges(); + + // 判断当前切割有没有割到95% + if (CalcTotalRange() >= 0.95) + { + Debug.Log("cutting All"); + OnCuttingDown?.Invoke(); + } // 打印当前所有区间(调试用) - Debug.Log("Current recorded ranges:"); + Debug.Log($"rangesCount:{_recordedRanges.Count}"); + + string log = "Ranges: "; foreach (Vector2 range in _recordedRanges) { - Debug.Log($"Range: {range.x} - {range.y}"); + log += $"{range.x:F2}-{range.y:F2}; "; } + Debug.Log(log); + + UpdateMaterial(); } - private float DistanceToSegment(Vector2 point, Vector2 segmentStart, Vector2 segmentEnd) + private bool TryGetCoverRange(Vector2 lineStart, Vector2 lineEnd, Vector2 point, float radius, + out Vector2 rawRange) { - Vector2 segment = segmentEnd - segmentStart; - Vector2 pointToStart = point - segmentStart; - - float dotProduct = Vector2.Dot(pointToStart, segment); - - // 检查点是否在线段的投影范围内 - if (dotProduct <= 0) + // 计算线段方向向量和长度 + Vector2 lineDir = lineEnd - lineStart; + float lineLength = lineDir.magnitude; + + // 如果线段长度为零(两个端点重合) + if (Mathf.Approximately(lineLength, 0f)) { - return Vector2.Distance(point, segmentStart); + // 检查点是否覆盖了这个点 + var distance = Vector2.Distance(lineStart, point); + rawRange = distance <= radius ? new Vector2(0f, 1f) : default; + return distance <= radius; + } + + // 计算点到线段所在直线距离 + Vector2 lineDirNormalized = lineDir / lineLength; // 归一化方向向量 + Vector2 pointToStart = point - lineStart; // 计算点到线段起点的向量 + float projection = Vector2.Dot(pointToStart, lineDirNormalized); // 计算投影长度(点在线段上的投影位置) + float closestT = Mathf.Clamp01(projection / lineLength); // 计算实际最近点在线段上的比例位置 + Vector2 closestPoint = lineStart + closestT * lineDir; // 计算最近点坐标 + float distanceToLine = Vector2.Distance(point, closestPoint); // 计算点到最近点的距离 + + // 如果距离大于半径,完全没有覆盖 + if (distanceToLine > radius) + { + rawRange = default; + return false; + } + + // 计算覆盖范围 + float halfCoveredLength = Mathf.Sqrt(radius * radius - distanceToLine * distanceToLine); // 计算实际覆盖的线段长度(勾股定理) + + float startCoverage = (projection - halfCoveredLength) / lineLength; + float endCoverage = (projection + halfCoveredLength) / lineLength; // 计算覆盖的起点和终点比例 + + startCoverage = Mathf.Clamp01(startCoverage); + endCoverage = Mathf.Clamp01(endCoverage); // 限制在0-1范围内 + + // 如果起点和终点相同,表示只覆盖了一个点 + if (Mathf.Approximately(startCoverage, endCoverage)) + { + rawRange = default; + return false; } - float segmentLengthSquared = segment.sqrMagnitude; - if (dotProduct >= segmentLengthSquared) - { - return Vector2.Distance(point, segmentEnd); - } - - // 计算垂直距离 - return Mathf.Abs(segmentStart.y * segmentEnd.x - segmentStart.x * segmentEnd.y + - point.x * (segmentStart.y - segmentEnd.y) + - point.y * (segmentEnd.x - segmentStart.x)) / - Mathf.Sqrt(segmentLengthSquared); + rawRange = new Vector2(startCoverage, endCoverage); + return true; } private void MergeRanges() @@ -173,7 +264,7 @@ namespace AibisDream Vector2 nextRange = _recordedRanges[i]; // 检查是否有重叠或相邻 - if (nextRange.x <= currentRange.y) + if (nextRange.x - currentRange.y <= 0.05f) { // 合并区间 currentRange.y = Mathf.Max(currentRange.y, nextRange.y); @@ -188,7 +279,12 @@ namespace AibisDream mergedRanges.Add(currentRange); _recordedRanges = mergedRanges; } - + + private float CalcTotalRange() + { + return _recordedRanges.Select(item => item.y - item.x).Sum(); + } + #endregion // 获取当前所有记录的范围(0-1之间的值) diff --git a/Assets/Scripts/FixSystemNew/BodyModule/Plug.cs b/Assets/Scripts/FixSystemNew/BodyModule/Plug.cs index e9cce832a..76c85c751 100644 --- a/Assets/Scripts/FixSystemNew/BodyModule/Plug.cs +++ b/Assets/Scripts/FixSystemNew/BodyModule/Plug.cs @@ -49,7 +49,7 @@ namespace AibisDream.FixSystem _trigger = GetComponent(); // 处理插头高亮 - _sprite.material.SetFloat(ShineFade, GlobalVariableKit.IsPlugHighLight ? 1 : 0); + // _sprite.material.SetFloat(ShineFade, GlobalVariableKit.IsPlugHighLight ? 1 : 0); } private void EventRegister() @@ -97,7 +97,7 @@ namespace AibisDream.FixSystem _cableSystem.CableRef.SetEndPos(_plugRootPos); _cableSystem.curSocket?.PlugOut(); - AudioManager.Instance.PlaySfx("event:/FollowInput/plugout"); + // AudioManager.Instance.PlaySfx("event:/FollowInput/plugout"); _sprite.enabled = true; if (_cableSystem.curSocket is BodyModule) diff --git a/Assets/Scripts/FixSystemNew/Clinic/ClinicSystem.cs b/Assets/Scripts/FixSystemNew/Clinic/ClinicSystem.cs index 9d9760faa..c473bd3c6 100644 --- a/Assets/Scripts/FixSystemNew/Clinic/ClinicSystem.cs +++ b/Assets/Scripts/FixSystemNew/Clinic/ClinicSystem.cs @@ -19,7 +19,7 @@ namespace AibisDream private void Awake() { FixSystemCenter.SystemDic.Register(this); - StorageSystem.Instance.RegisterData(_clinicData); + // StorageSystem.Instance.RegisterData(_clinicData); character = transform.GetComponentInChildren(); character.CharacterChangeEvent += OnCharacterChange; diff --git a/Assets/Scripts/FixSystemNew/FixSystemCenter.cs b/Assets/Scripts/FixSystemNew/FixSystemCenter.cs index 169381970..9909665ea 100644 --- a/Assets/Scripts/FixSystemNew/FixSystemCenter.cs +++ b/Assets/Scripts/FixSystemNew/FixSystemCenter.cs @@ -19,7 +19,7 @@ namespace AibisDream.FixSystem StartCoroutine(StateMachine.SwitchState(FixState.Clinic)); // 注册 - StorageSystem.Instance.RegisterData(_data); + // StorageSystem.Instance.RegisterData(_data); } public override void OnSingletonDestroy() diff --git a/Assets/Scripts/FixSystemNew/Screen System/ScreenSystem.cs b/Assets/Scripts/FixSystemNew/Screen System/ScreenSystem.cs index 2b4ae0254..ca493bf11 100644 --- a/Assets/Scripts/FixSystemNew/Screen System/ScreenSystem.cs +++ b/Assets/Scripts/FixSystemNew/Screen System/ScreenSystem.cs @@ -47,7 +47,7 @@ namespace AibisDream.FixSystem private void Register() { FixSystemCenter.SystemDic.Register(this); - DialogCanvasManager.Instance.RegisterDialogView(DialogViewType.Screen, this); + // DialogCanvasManager.Instance.RegisterDialogView(DialogViewType.Screen, this); } private void OnDestroy() diff --git a/Assets/Scripts/Framework/OtherKit/MonoCenter.cs b/Assets/Scripts/Framework/OtherKit/MonoCenter.cs index f8eee4c2b..44f515443 100644 --- a/Assets/Scripts/Framework/OtherKit/MonoCenter.cs +++ b/Assets/Scripts/Framework/OtherKit/MonoCenter.cs @@ -1,5 +1,6 @@ using System; using AibisDream.FixSystem; +using AibisDream.Utility; using UnityEngine; namespace AibisDream.Framework @@ -11,6 +12,8 @@ namespace AibisDream.Framework public static MonoCenter Mono; private static IOCContainer _iocContainer; + public SpriteRenderer cursor; + private void Awake() { if (Mono) @@ -40,7 +43,13 @@ namespace AibisDream.Framework OnUpdate -= kit.OnUpdate; } - private void Update() => OnUpdate?.Invoke(); + private void Update() + { + OnUpdate?.Invoke(); + // var worldPos = CommonUtil.GetMouseWorldPos(Input.mousePosition); + // worldPos.z = 0; + // cursor.transform.position = worldPos; + } } public class TransTest : IMonoKit @@ -56,7 +65,7 @@ namespace AibisDream.Framework { var bodyModuleSystem = FixSystemCenter.SystemDic.Get(); var module = bodyModuleSystem.FindBodyModuleByName("Memory"); - + Debug.Log(module.name); module.EnableCut(); } } diff --git a/Assets/Scripts/Framework/ResourceKit/ResourceKit.cs b/Assets/Scripts/Framework/ResourceKit/ResourceKit.cs index 9f80812a2..06323ba8e 100644 --- a/Assets/Scripts/Framework/ResourceKit/ResourceKit.cs +++ b/Assets/Scripts/Framework/ResourceKit/ResourceKit.cs @@ -60,20 +60,11 @@ namespace AibisDream.Framework public static T LoadAssetSync(string key) where T : UnityEngine.Object { - T result = null; var operation = Addressables.LoadAssetAsync(key); - // 运行协程等待加载完成 - GameManager.Instance.StartCoroutine(LoadCoroutine(operation, loadedObject => result = loadedObject)); + operation.WaitForCompletion(); - // 等待协程完成(阻塞主线程) - while (!operation.IsDone) - { - // 主动让出一帧 - System.Threading.Thread.Sleep(1); - } - - return result; + return operation.Result; } private static IEnumerator LoadCoroutine(AsyncOperationHandle operation, Action onComplete) diff --git a/Assets/Scripts/Utility/GlobalVariableKit.cs b/Assets/Scripts/Utility/GlobalVariableKit.cs index 0c83ca7a0..0c380be69 100644 --- a/Assets/Scripts/Utility/GlobalVariableKit.cs +++ b/Assets/Scripts/Utility/GlobalVariableKit.cs @@ -1,17 +1,24 @@ -namespace AibisDream.Utility +using UnityEngine; + +namespace AibisDream.Utility { public static class GlobalVariableKit { public static bool IsPlugHighLight { - get => !(StorageSystem.Instance.TryGetValue("$global.IsPlugHighLight", out bool res) && res); - set => StorageSystem.Instance.SetValue("$global.IsPlugHighLight", !value); + // get => !(StorageSystem.Instance.TryGetValue("$global.IsPlugHighLight", out bool res) && res); + // set => StorageSystem.Instance.SetValue("$global.IsPlugHighLight", !value); + get => false; + set => Debug.Log(value); } public static bool IsCordHighLight { - get => !(StorageSystem.Instance.TryGetValue("$global.IsCurdHighLight", out bool res) && res); - set => StorageSystem.Instance.SetValue("$global.IsCurdHighLight", !value); + // get => !(StorageSystem.Instance.TryGetValue("$global.IsCurdHighLight", out bool res) && res); + // set => StorageSystem.Instance.SetValue("$global.IsCurdHighLight", !value); + + get => false; + set => Debug.Log(value); } } } \ No newline at end of file diff --git a/Assets/Shader/Material/CutLineMaterial.mat b/Assets/Shader/Material/CutLineMaterial.mat index 6d295968a..e9b708de5 100644 --- a/Assets/Shader/Material/CutLineMaterial.mat +++ b/Assets/Shader/Material/CutLineMaterial.mat @@ -65,7 +65,7 @@ Material: m_Colors: - _Color: {r: 1, g: 1, b: 1, a: 1} - _Flip: {r: 1, g: 1, b: 1, a: 1} - - _Ranges: {r: 0.05, g: 0.2, b: 0.43, a: 0.63} + - _Ranges: {r: 0, g: 0, b: 0, a: 0} - _RendererColor: {r: 1, g: 1, b: 1, a: 1} - _TintColor: {r: 1, g: 0, b: 0, a: 1} m_BuildTextureStacks: []