diff --git a/Assets/Materials/Compose/Waveform.mat b/Assets/Materials/Compose/Waveform.mat index f15e884e..9002b3dd 100644 --- a/Assets/Materials/Compose/Waveform.mat +++ b/Assets/Materials/Compose/Waveform.mat @@ -74,7 +74,7 @@ Material: - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _SrcBlend: 1 - - _ToSample: 13918327 + - _ToSample: 0 - _UVSec: 0 - _ZWrite: 1 m_Colors: diff --git a/Assets/Scenes/Compose.unity b/Assets/Scenes/Compose.unity index 5064c1a8..4c1b13e1 100644 --- a/Assets/Scenes/Compose.unity +++ b/Assets/Scenes/Compose.unity @@ -95253,7 +95253,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 342982843} m_HandleRect: {fileID: 342982842} m_Direction: 2 - m_Value: 0 + m_Value: 1 m_Size: 1 m_NumberOfSteps: 0 m_OnValueChanged: @@ -106478,7 +106478,7 @@ MonoBehaviour: m_HandleRect: {fileID: 505154476} m_Direction: 2 m_Value: 1.000001 - m_Size: 0.92044705 + m_Size: 0.9204472 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: diff --git a/Assets/Scripts/Compose/Project/RawEditor/Component/LineHighlightComponent.cs b/Assets/Scripts/Compose/Project/RawEditor/Component/LineHighlightComponent.cs index f06ccd1a..047c71bf 100644 --- a/Assets/Scripts/Compose/Project/RawEditor/Component/LineHighlightComponent.cs +++ b/Assets/Scripts/Compose/Project/RawEditor/Component/LineHighlightComponent.cs @@ -18,7 +18,7 @@ public class LineHighlightComponent : MonoBehaviour, IPointerEnterHandler private string text; private Severity severity; - public void SetPosition(TextGenerator gen, Option lineNumber, Option startCharPos, Option length) + public void SetPosition(TextGenerator gen, float pixelPerUnit, Option lineNumber, Option startCharPos, Option length) { if (rect == null) { @@ -36,7 +36,7 @@ public void SetPosition(TextGenerator gen, Option lineNumber, Option s UILineInfo lineInfo = lineInfoArray[lineNumVal]; UILineInfo firstLineInfo = lineInfoArray[0]; - float ascender = firstLineInfo.topY - lineInfo.topY - (lineInfo.leading * lineNumVal); + float ascender = (firstLineInfo.topY - lineInfo.topY) / pixelPerUnit; if (!startCharPos.HasValue) { @@ -45,7 +45,7 @@ public void SetPosition(TextGenerator gen, Option lineNumber, Option s rect.offsetMin = new Vector2(0, rect.offsetMin.y); rect.offsetMax = new Vector2(0, rect.offsetMax.y); rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, -ascender); - rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, lineInfo.height); + rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, lineInfo.height / pixelPerUnit); } else { @@ -63,13 +63,13 @@ public void SetPosition(TextGenerator gen, Option lineNumber, Option s float left = (leftIndex >= 0 && leftIndex < charInfoArray.Count) ? charInfoArray[leftIndex].cursorPos.x : 0; float right = (rightIndex >= 0 && rightIndex < charInfoArray.Count) ? charInfoArray[rightIndex].cursorPos.x + charInfoArray[rightIndex].charWidth : left + MinWidth; - left += (leftIndex - lineInfo.startCharIdx) * 0.4f; - right += (rightIndex - lineInfo.startCharIdx) * 0.4f; + left /= pixelPerUnit; + right /= pixelPerUnit; rect.anchorMin = new Vector2(0f, 1f); rect.anchorMax = new Vector2(0f, 1f); rect.anchoredPosition = new Vector2((left + right) / 2, -ascender); - rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, lineInfo.height); + rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, lineInfo.height / pixelPerUnit); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.Abs(right - left)); } } diff --git a/Assets/Scripts/Compose/Project/RawEditor/RawEditor.cs b/Assets/Scripts/Compose/Project/RawEditor/RawEditor.cs index 2ccc382c..f188c850 100644 --- a/Assets/Scripts/Compose/Project/RawEditor/RawEditor.cs +++ b/Assets/Scripts/Compose/Project/RawEditor/RawEditor.cs @@ -240,7 +240,7 @@ private async UniTask OnValueChangedTask(string val, CancellationToken ct) private void DisplayFault(ChartFault fault) { LineHighlightComponent line = lineHighlightPool.Get(); - line.SetPosition(inputField.TextGenerator, fault.LineNumber, fault.StartCharPos, fault.Length); + line.SetPosition(inputField.TextGenerator, inputField.PixelPerUnit, fault.LineNumber, fault.StartCharPos, fault.Length); line.SetContent(fault.Severity, fault.Description); ScrollHighlightComponent scroll = scrollHighlightPool.Get(); diff --git a/Assets/Scripts/Utility/Components/FastInputField.cs b/Assets/Scripts/Utility/Components/FastInputField.cs index 64b55c1d..baa411d2 100644 --- a/Assets/Scripts/Utility/Components/FastInputField.cs +++ b/Assets/Scripts/Utility/Components/FastInputField.cs @@ -38,6 +38,8 @@ public class FastInputField : InputField, IScrollHandler public TextGenerator TextGenerator => cachedInputTextGenerator; + public float PixelPerUnit => m_TextComponent.pixelsPerUnit; + private RectTransform Rect { get @@ -341,7 +343,7 @@ private void UpdateScrollbarVerticalPosition() TextGenerator gen = cachedInputTextGenerator; UILineInfo firstLine = gen.lines[0]; UILineInfo startLine = gen.lines[line]; - float y = firstLine.topY - startLine.topY - (startLine.leading * line); + float y = (firstLine.topY - startLine.topY) / m_TextComponent.pixelsPerUnit; float val = y / (contentSize.y - gen.rectExtents.size.y); OnScrollVerticalChanged?.Invoke(y); verticalScrollbar.SetValueWithoutNotify(val);