diff --git a/Assets/AddressableAssetsData/link.xml b/Assets/AddressableAssetsData/link.xml new file mode 100644 index 000000000..1942a3b44 --- /dev/null +++ b/Assets/AddressableAssetsData/link.xml @@ -0,0 +1,417 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Assets/AddressableAssetsData/link.xml.meta b/Assets/AddressableAssetsData/link.xml.meta new file mode 100644 index 000000000..3b66be35a --- /dev/null +++ b/Assets/AddressableAssetsData/link.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8d89df90342601c4aa6e842493d9766c +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/DialogLine.cs b/Assets/DialogLine.cs new file mode 100644 index 000000000..574c500c3 --- /dev/null +++ b/Assets/DialogLine.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AibisDream +{ + public class DialogLine : MonoBehaviour + { + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } + } +} diff --git a/Assets/DialogLine.cs.meta b/Assets/DialogLine.cs.meta new file mode 100644 index 000000000..9c121c74e --- /dev/null +++ b/Assets/DialogLine.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: addb57296dac0c2429dd969b61b69940 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Language/Dialog/FP_Shitou1/FP_Shitou1_en.asset b/Assets/Language/Dialog/FP_Shitou1/FP_Shitou1_en.asset index 9b0ac7957..159c590e8 100644 --- a/Assets/Language/Dialog/FP_Shitou1/FP_Shitou1_en.asset +++ b/Assets/Language/Dialog/FP_Shitou1/FP_Shitou1_en.asset @@ -169,7 +169,7 @@ MonoBehaviour: m_Metadata: m_Items: [] - m_Id: 2607929102368 - m_Localized: 'Analysing: nan' + m_Localized: 'Analysing: ' m_Metadata: m_Items: [] - m_Id: 2607929102369 @@ -177,7 +177,7 @@ MonoBehaviour: m_Metadata: m_Items: [] - m_Id: 2607929102370 - m_Localized: 'LungModule: nan' + m_Localized: 'LungModule: ' m_Metadata: m_Items: [] - m_Id: 2607929102371 @@ -219,7 +219,7 @@ MonoBehaviour: m_Metadata: m_Items: [] - m_Id: 2607929102380 - m_Localized: 'Analysing: nan' + m_Localized: 'Analysing: ' m_Metadata: m_Items: [] - m_Id: 2607929102381 @@ -336,7 +336,7 @@ MonoBehaviour: m_Metadata: m_Items: [] - m_Id: 2607929102407 - m_Localized: 'Analysing: nan' + m_Localized: 'Analysing: ' m_Metadata: m_Items: [] - m_Id: 2607929102408 @@ -344,7 +344,7 @@ MonoBehaviour: m_Metadata: m_Items: [] - m_Id: 2607929102409 - m_Localized: 'DigestModule: nan' + m_Localized: 'DigestModule: ' m_Metadata: m_Items: [] - m_Id: 2607929102410 @@ -401,11 +401,11 @@ MonoBehaviour: m_Metadata: m_Items: [] - m_Id: 2607929102422 - m_Localized: 'Analysing: nan' + m_Localized: 'Analysing: ' m_Metadata: m_Items: [] - m_Id: 2607929102423 - m_Localized: 'LiverModule: nan' + m_Localized: 'LiverModule: ' m_Metadata: m_Items: [] - m_Id: 2607929102424 @@ -413,7 +413,7 @@ MonoBehaviour: m_Metadata: m_Items: [] - m_Id: 2607929102425 - m_Localized: 'LiverModule: nan' + m_Localized: 'LiverModule: ' m_Metadata: m_Items: [] - m_Id: 2607929102426 diff --git a/Assets/Prefabs/FixSystemPrefabs/Screen System.prefab b/Assets/Prefabs/FixSystemPrefabs/Screen System.prefab index f88260cc0..ee3437620 100644 --- a/Assets/Prefabs/FixSystemPrefabs/Screen System.prefab +++ b/Assets/Prefabs/FixSystemPrefabs/Screen System.prefab @@ -251,6 +251,7 @@ MonoBehaviour: m_EditorClassIdentifier: rotateDuration: 0.5 typeSpeed: 0.015 + maxTextLine: 9 title: {fileID: 3563212816421902004} text: {fileID: 4278472285296606170} screenImage: {fileID: 107892122242889724} diff --git a/Assets/Prefabs/UIprefab/Task Item.prefab b/Assets/Prefabs/UIprefab/Task Item.prefab index f5467d61b..7bc8ff9bf 100644 --- a/Assets/Prefabs/UIprefab/Task Item.prefab +++ b/Assets/Prefabs/UIprefab/Task Item.prefab @@ -11,7 +11,9 @@ GameObject: - component: {fileID: 4119798753652615804} - component: {fileID: 8451937555351605602} - component: {fileID: 8668285234604897857} - - component: {fileID: 2523308370879421851} + - component: {fileID: 8694252804462978991} + - component: {fileID: 1501832309215763035} + - component: {fileID: -6166291495296749313} m_Layer: 5 m_Name: Task Item m_TagString: Untagged @@ -36,7 +38,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 320, y: 50} + m_SizeDelta: {x: 320, y: 35} m_Pivot: {x: 0, y: 0.5} --- !u!222 &8451937555351605602 CanvasRenderer: @@ -93,15 +95,15 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 25 - m_fontSizeBase: 25 + m_fontSize: 28 + m_fontSizeBase: 28 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 18 m_fontSizeMax: 72 m_fontStyle: 1 m_HorizontalAlignment: 1 - m_VerticalAlignment: 256 + m_VerticalAlignment: 512 m_textAlignment: 65535 m_characterSpacing: 0 m_wordSpacing: 0 @@ -135,7 +137,7 @@ MonoBehaviour: m_hasFontAssetChanged: 0 m_baseMaterial: {fileID: 0} m_maskOffset: {x: 0, y: 0, z: 0, w: 0} ---- !u!114 &2523308370879421851 +--- !u!114 &8694252804462978991 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -159,19 +161,33 @@ MonoBehaviour: m_FormatArguments: [] m_UpdateString: m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 8668285234604897857} - m_TargetAssemblyTypeName: TMPro.TMP_Text, Unity.TextMeshPro - m_MethodName: set_text - m_Mode: 0 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 1 + m_Calls: [] references: version: 2 RefIds: [] +--- !u!114 &1501832309215763035 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7125762734194905057} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4c9c71a7e9c9455d955ff20b5db823a1, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &-6166291495296749313 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7125762734194905057} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalFit: 0 + m_VerticalFit: 2 diff --git a/Assets/RawResources/Icon/pointer_c.png.meta b/Assets/RawResources/Icon/pointer_c.png.meta index 0a8fa762f..47fc31f29 100644 --- a/Assets/RawResources/Icon/pointer_c.png.meta +++ b/Assets/RawResources/Icon/pointer_c.png.meta @@ -34,7 +34,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: 0 + filterMode: 1 aniso: 1 mipBias: 0 wrapU: 1 @@ -46,8 +46,8 @@ TextureImporter: spriteMode: 1 spriteExtrude: 1 spriteMeshType: 1 - alignment: 9 - spritePivot: {x: 0.140625, y: 0.875} + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} spritePixelsToUnits: 100 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 @@ -72,7 +72,7 @@ TextureImporter: maxTextureSize: 2048 resizeAlgorithm: 0 textureFormat: -1 - textureCompression: 0 + textureCompression: 1 compressionQuality: 50 crunchedCompression: 0 allowsAlphaSplitting: 0 @@ -139,7 +139,7 @@ TextureImporter: physicsShape: [] bones: [] spriteID: 5e97eb03825dee720800000000000000 - internalID: 1537655665 + internalID: 0 vertices: [] indices: edges: [] diff --git a/Assets/Scenes/Persistence.unity b/Assets/Scenes/Persistence.unity index 10ee3cff7..e8e65f2c8 100644 --- a/Assets/Scenes/Persistence.unity +++ b/Assets/Scenes/Persistence.unity @@ -2893,7 +2893,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchoredPosition: {x: 200, y: 0} m_SizeDelta: {x: 0, y: 80} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &190932926 @@ -3970,7 +3970,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchoredPosition: {x: 200, y: 0} m_SizeDelta: {x: 0, y: 80} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &237392156 @@ -5825,7 +5825,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -350} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 350, y: 350} m_Pivot: {x: 0, y: 0} --- !u!222 &425473021 @@ -20608,7 +20608,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchoredPosition: {x: 200, y: 0} m_SizeDelta: {x: 0, y: 80} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1611684201 @@ -22073,8 +22073,7 @@ RectTransform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 2033733147} + m_Children: [] m_Father: {fileID: 425473020} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -22100,9 +22099,9 @@ MonoBehaviour: m_Top: 0 m_Bottom: 0 m_ChildAlignment: 0 - m_Spacing: 0 + m_Spacing: 10 m_ChildForceExpandWidth: 1 - m_ChildForceExpandHeight: 1 + m_ChildForceExpandHeight: 0 m_ChildControlWidth: 0 m_ChildControlHeight: 0 m_ChildScaleWidth: 0 @@ -23990,9 +23989,9 @@ RectTransform: m_Children: [] m_Father: {fileID: 1696845842} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 200, y: -150} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 200, y: 0} m_SizeDelta: {x: 0, y: 80} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1960600463 @@ -25167,11 +25166,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2019424939} m_CullTransparentMesh: 1 ---- !u!224 &2033733147 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - m_PrefabInstance: {fileID: 2038189805314920883} - m_PrefabAsset: {fileID: 0} --- !u!1 &2034573581 GameObject: m_ObjectHideFlags: 0 @@ -34129,103 +34123,6 @@ MonoBehaviour: m_EffectColor: {r: 1, g: 0.58, b: 0.04, a: 1} m_EffectDistance: {x: 3, y: -3} m_UseGraphicAlpha: 1 ---- !u!1001 &2038189805314920883 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 1775784970} - m_Modifications: - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_Pivot.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_Pivot.y - value: 0.5 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_AnchorMax.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_AnchorMax.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_AnchorMin.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_AnchorMin.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_SizeDelta.x - value: 320 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_SizeDelta.y - value: 50 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_LocalRotation.x - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_LocalRotation.y - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_LocalRotation.z - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_AnchoredPosition.x - value: 40 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_AnchoredPosition.y - value: -25 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4119798753652615804, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7125762734194905057, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} - propertyPath: m_Name - value: Task Item - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: b7c1973c6f77b0b4eab9a1da8b6a03df, type: 3} --- !u!224 &2041500036121329234 RectTransform: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/FixSystemNew/Screen System/ScreenSystem.cs b/Assets/Scripts/FixSystemNew/Screen System/ScreenSystem.cs index ee4342429..5daeb3393 100644 --- a/Assets/Scripts/FixSystemNew/Screen System/ScreenSystem.cs +++ b/Assets/Scripts/FixSystemNew/Screen System/ScreenSystem.cs @@ -16,6 +16,7 @@ namespace AibisDream.FixSystem public float rotateDuration = 0.5f; public float typeSpeed = 0.05f; + public int maxTextLine; #endregion @@ -26,9 +27,12 @@ namespace AibisDream.FixSystem [SerializeField] private TMP_Text text; [SerializeField] private SpriteRenderer screenImage; private Material _imageMaterial; + private Action _nextStep; + + private TextGenerator _generator; + private TextGenerationSettings _generationSettings; private IUnRegister _plugOutRmv; - private Action _nextStep; #endregion @@ -42,6 +46,18 @@ namespace AibisDream.FixSystem { _textScreen = transform.Find("旋转屏幕"); _imageMaterial = screenImage.material; + + _generator = new TextGenerator(); + _generationSettings = new TextGenerationSettings + { + font = text.font.sourceFontFile, + fontSize = Mathf.RoundToInt(text.fontSize), + lineSpacing = text.lineSpacing, + horizontalOverflow = HorizontalWrapMode.Wrap, + verticalOverflow = VerticalWrapMode.Truncate, + generationExtents = new Vector2(text.rectTransform.rect.width, Mathf.Infinity), + resizeTextForBestFit = false + }; } private void Register() @@ -76,18 +92,43 @@ namespace AibisDream.FixSystem { text.text += "\n"; } + // 先估算新增行数 + var targetLineNum = EstimateLineNum(targetText); + // 截断超出屏幕的部分 + var oldText = ""; + if (targetLineNum + text.textInfo.lineCount > maxTextLine) + { + var cutLineNum = targetLineNum + text.textInfo.lineCount - maxTextLine; + if (cutLineNum <= text.textInfo.lineCount) + { + var lastCharIndex = text.textInfo.lineInfo[cutLineNum - 1].lastCharacterIndex; + oldText = text.text[lastCharIndex..]; + } + } + else + { + oldText = text.text; + } - var oldText = text.text; - var targetLength = text.text.Length + targetText.Length; + var targetLength = oldText.Length + targetText.Length; + // 逐个字符添加 - yield return DOTween.To(() => text.text.Length, x => UpdateText(x, targetText, oldText), targetLength, + yield return DOTween.To(() => oldText.Length, x => UpdateText(x, targetText, oldText), targetLength, targetText.Length * typeSpeed).WaitForCompletion(); EnumEventSystem.Global.Send(DialogEventEnum.LineShown); yield return new WaitForSeconds(0.5f); EnumEventSystem.Global.Send(DialogEventEnum.LineEnd); _nextStep.Invoke(); } + + private int EstimateLineNum(string str) + { + var height = _generator.GetPreferredHeight(str, _generationSettings); + var lineHeight = text.fontSize * 1.2f; // 简单估算行高 + + return Mathf.CeilToInt(height / lineHeight); + } private void UpdateText(int currentLength, string nextText, string oldText) { diff --git a/Assets/Scripts/Framework/ResourceKit/ResourceKit.cs b/Assets/Scripts/Framework/ResourceKit/ResourceKit.cs index 45fdb6ef4..ca1a2b2f4 100644 --- a/Assets/Scripts/Framework/ResourceKit/ResourceKit.cs +++ b/Assets/Scripts/Framework/ResourceKit/ResourceKit.cs @@ -13,7 +13,7 @@ namespace AibisDream.Framework { #if UNITY_EDITOR if (!sprite) return ""; - + // 先读Psd的路径 string psdPath = AssetDatabase.GetAssetPath(sprite); var psdResPath = GetResourcePath(psdPath); @@ -28,13 +28,12 @@ namespace AibisDream.Framework // 提取文件名(不包括扩展名) var purePath = psdResPath.Substring(0, lastDotIndex); - + // 添加后缀 return purePath + "/" + sprite.name; #else return null; #endif - } private static string GetResourcePath(string absolutePath) @@ -42,15 +41,7 @@ namespace AibisDream.Framework const string resourcesFolderName = "Resources/"; int index = absolutePath.IndexOf(resourcesFolderName, StringComparison.Ordinal); - if (index >= 0) - { - // 获取 "Resources/" 之后的部分 - return absolutePath.Substring(index + resourcesFolderName.Length); - } - else - { - return absolutePath; - } + return index >= 0 ? absolutePath[(index + resourcesFolderName.Length)..] : absolutePath; } public static Sprite LoadSpriteFromPsd(string path) @@ -58,7 +49,7 @@ namespace AibisDream.Framework int lastIndex = path.LastIndexOf('/'); string spriteName = path.Substring(lastIndex + 1); string resPath = path.Substring(0, lastIndex); - + // 加载 var sprites = Resources.LoadAll(resPath); @@ -72,39 +63,14 @@ namespace AibisDream.Framework return null; } - - public static T LoadAddressableSync(string key) + + public static T LoadAssetSync(string key) where T : UnityEngine.Object { - T result = default; var operation = Addressables.LoadAssetAsync(key); - - // 运行协程等待加载完成 - GameManager.Instance.StartCoroutine(LoadCoroutine(operation, loadedObject => result = loadedObject)); - // 等待协程完成(阻塞主线程) - while (!operation.IsDone) - { - // 主动让出一帧 - System.Threading.Thread.Sleep(1); - } + operation.WaitForCompletion(); - return result; - } - - public static IEnumerator LoadCoroutine(AsyncOperationHandle operation, Action onComplete) - { - yield return operation; - - if (operation.Status == AsyncOperationStatus.Succeeded) - { - onComplete?.Invoke(operation.Result); - } - else - { - Debug.LogError("Failed to load addressable"); - } - - Addressables.Release(operation); + return operation.Result; } } } \ No newline at end of file diff --git a/Assets/Scripts/UI/DialogUI/LocalizedText.cs b/Assets/Scripts/UI/DialogUI/LocalizedText.cs new file mode 100644 index 000000000..a57837944 --- /dev/null +++ b/Assets/Scripts/UI/DialogUI/LocalizedText.cs @@ -0,0 +1,31 @@ +using TMPro; +using UnityEngine; +using UnityEngine.Localization.Components; + +namespace AibisDream +{ + [RequireComponent(typeof(TMP_Text))] + [RequireComponent(typeof(LocalizeStringEvent))] + public class LocalizedText : MonoBehaviour + { + private TMP_Text _text; + private LocalizeStringEvent _localizeEvent; + + private void OnUpdateString(string text) + { + var textArr = text.Split(":"); + _text.text = textArr.Length > 1 ? textArr[1].Trim() : text; + } + + public void SetLocalizedText(string table, string entry) + { + _text = GetComponent(); + _localizeEvent = GetComponent(); + + _localizeEvent.OnUpdateString.AddListener(OnUpdateString); + + _localizeEvent.SetTable(table); + _localizeEvent.SetEntry(entry); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/DialogUI/LocalizedText.cs.meta b/Assets/Scripts/UI/DialogUI/LocalizedText.cs.meta new file mode 100644 index 000000000..37499138a --- /dev/null +++ b/Assets/Scripts/UI/DialogUI/LocalizedText.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4c9c71a7e9c9455d955ff20b5db823a1 +timeCreated: 1746702086 \ No newline at end of file diff --git a/Assets/Scripts/UI/Panel/TaskPanel.cs b/Assets/Scripts/UI/Panel/TaskPanel.cs index 0eaf458db..1976530b9 100644 --- a/Assets/Scripts/UI/Panel/TaskPanel.cs +++ b/Assets/Scripts/UI/Panel/TaskPanel.cs @@ -7,24 +7,36 @@ using AibisDream.Utility; using DG.Tweening; using TMPro; using UnityEngine; -using UnityEngine.Localization.Components; using Yarn.Unity; namespace AibisDream { public class TaskPanel : MonoBehaviour, IUIPanel, IDialogView { + private RectTransform _rectTransform; private Transform _taskListParent; private GameObject _taskItemPrefab; - private readonly Dictionary _taskDict = new(); + private GameObject TaskItemPrefab + { + get + { + if (_taskItemPrefab == null) + { + _taskItemPrefab = ResourceKit.LoadAssetSync(ConstRef.TaskItemName); + } + + return _taskItemPrefab; + } + } + + private readonly Dictionary _taskDict = new(); private void Awake() { + _rectTransform = GetComponent(); _taskListParent = transform.Find("Record"); - _taskItemPrefab = ResourceKit.LoadAddressableSync(ConstRef.TaskItemName); EnumEventSystem.Global.Register(GameLoopEnum.GameQuit, ClearTasks); - DialogCanvasManager.Instance.RegisterDialogView(DialogViewType.Task, this); } #region 诊疗单功能 @@ -33,7 +45,9 @@ namespace AibisDream { if (_taskDict.TryGetValue(lineId, out var taskItem)) { - taskItem.GetComponent().fontStyle |= FontStyles.Strikethrough; + var taskText = taskItem.GetComponent(); + taskText.fontStyle |= FontStyles.Strikethrough; + taskText.color = Color.gray; } } @@ -52,14 +66,15 @@ namespace AibisDream public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId, bool isAutoSkip = false) { - var taskItem = Instantiate(_taskItemPrefab, _taskListParent); + var taskItem = Instantiate(TaskItemPrefab, _taskListParent); // 设置本地化数据 - var localize = taskItem.GetComponent(); - localize.SetTable(DialogController.Instance.GetCurLocalizedTableName()); - localize.SetEntry(lineId); - _taskDict[lineId] = taskItem; - - ActionKit.Delay(0.5f, nextStep); + var localize = taskItem.GetComponent(); + localize.SetLocalizedText(DialogController.Instance.GetCurLocalizedTableName(), lineId); + _taskDict[lineId] = localize; + + EnumEventSystem.Global.Send(DialogEventEnum.LineShown); + EnumEventSystem.Global.Send(DialogEventEnum.LineEnd); + nextStep.Invoke(); } public void ShowOptions(DialogOption[] dialogueOptions) @@ -85,7 +100,6 @@ namespace AibisDream #endregion - #region 打开和关闭 public bool IsOpen { get; private set;} @@ -95,7 +109,7 @@ namespace AibisDream gameObject.SetActive(true); AudioManager.Instance.PlaySfx("event:/Scriptal/taskmanager"); // 下移 - transform.DOLocalMoveY(-350, 1f).OnComplete(() => + _rectTransform.DOAnchorPosY(-350, 1f).OnComplete(() => { IsOpen = true; }); @@ -105,7 +119,7 @@ namespace AibisDream { // 上移 AudioManager.Instance.PlaySfx("event:/Scriptal/taskmanager"); - transform.DOLocalMoveY(0, 1f).OnComplete(() => + _rectTransform.DOAnchorPosY(0, 1f).OnComplete(() => { gameObject.SetActive(false); IsOpen = false; @@ -117,7 +131,7 @@ namespace AibisDream public static class TaskYarnCommand { - private static TaskPanel TaskPanel => UIManager.Instance.GetComponent(); + private static TaskPanel TaskPanel => UIManager.Instance.GetPanel(); [YarnCommand("complete_task")] public static void CompleteTask(string lineId) diff --git a/Assets/Scripts/Utility/CommonUtil.cs b/Assets/Scripts/Utility/CommonUtil.cs index 534420b30..e7e52965e 100644 --- a/Assets/Scripts/Utility/CommonUtil.cs +++ b/Assets/Scripts/Utility/CommonUtil.cs @@ -206,7 +206,7 @@ namespace AibisDream.Utility } } - result.Append(substring); + result.Append(substring.TrimStart()); currentIndex += length; if (currentIndex < line.Length) diff --git a/Assets/StreamingAssets/LevelData/GearSystem/temp.json b/Assets/StreamingAssets/LevelData/GearSystem/temp.json index 25f38f562..c9b096ae7 100644 --- a/Assets/StreamingAssets/LevelData/GearSystem/temp.json +++ b/Assets/StreamingAssets/LevelData/GearSystem/temp.json @@ -1 +1 @@ -{"shaftLevelDataArray":[{"shaftName":"Pluggable Shaft3","shaftType":3,"targetSpeed":0.0,"hasChildGear":true,"radius":0.4,"gearProp":"","isGearBroken":false,"isDisc":true,"discIdx":0,"shaftPos":{"x":-1.232,"y":-0.319,"z":0.0},"gearPicPath":"Art/Fix/变速箱齿轮/刻录齿轮"},{"shaftName":"Pluggable Shaft2","shaftType":3,"targetSpeed":0.0,"hasChildGear":true,"radius":0.3,"gearProp":"","isGearBroken":false,"isDisc":false,"discIdx":0,"shaftPos":{"x":-2.54,"y":-0.525,"z":0.0},"gearPicPath":"Art/Fix/变速箱齿轮/镍铬齿轮B"},{"shaftName":"Pluggable Shaft1","shaftType":3,"targetSpeed":0.0,"hasChildGear":true,"radius":0.5,"gearProp":"","isGearBroken":false,"isDisc":false,"discIdx":0,"shaftPos":{"x":-1.861,"y":-0.922,"z":0.0},"gearPicPath":"Art/Fix/变速箱齿轮/镍铬齿轮C"},{"shaftName":"Driver Shaft","shaftType":0,"targetSpeed":0.0,"hasChildGear":true,"radius":0.49,"gearProp":"","isGearBroken":false,"isDisc":false,"discIdx":0,"shaftPos":{"x":-2.263,"y":0.193,"z":0.0},"gearPicPath":"Art/Fix/变速箱齿轮/镍铬齿轮A"}],"panelShaftArray":[]} \ No newline at end of file +{"shaftLevelDataArray":[{"shaftName":"Pluggable Shaft3","shaftType":2,"targetSpeed":0.0,"hasChildGear":true,"radius":0.4,"gearProp":"","isGearBroken":false,"isDisc":true,"discIdx":0,"shaftPos":{"x":-1.232,"y":-0.319,"z":0.0},"gearPicPath":"Art/Fix/变速箱齿轮/唱片齿轮"},{"shaftName":"Pluggable Shaft2","shaftType":2,"targetSpeed":0.0,"hasChildGear":true,"radius":0.3,"gearProp":"","isGearBroken":false,"isDisc":false,"discIdx":0,"shaftPos":{"x":-2.54,"y":-0.525,"z":0.0},"gearPicPath":"Art/Fix/变速箱齿轮/普通齿轮B"},{"shaftName":"Pluggable Shaft1","shaftType":2,"targetSpeed":0.0,"hasChildGear":true,"radius":0.5,"gearProp":"","isGearBroken":false,"isDisc":false,"discIdx":0,"shaftPos":{"x":-1.861,"y":-0.922,"z":0.0},"gearPicPath":"Art/Fix/变速箱齿轮/普通齿轮C"},{"shaftName":"Driver Shaft","shaftType":0,"targetSpeed":0.0,"hasChildGear":true,"radius":0.49,"gearProp":"","isGearBroken":false,"isDisc":false,"discIdx":0,"shaftPos":{"x":-2.263,"y":0.193,"z":0.0},"gearPicPath":"Art/Fix/变速箱齿轮/普通齿轮A"}],"panelShaftArray":[{"shaftName":"Panel Shaft1","shaftType":2,"targetSpeed":0.0,"hasChildGear":true,"radius":0.5,"gearProp":"","isGearBroken":false,"isDisc":false,"discIdx":0,"shaftPos":{"x":-0.015,"y":0.883,"z":0.0},"gearPicPath":"Art/Fix/变速箱齿轮/普通齿轮C"},{"shaftName":"Panel Shaft2","shaftType":2,"targetSpeed":0.0,"hasChildGear":true,"radius":0.3,"gearProp":"","isGearBroken":false,"isDisc":false,"discIdx":0,"shaftPos":{"x":-0.007,"y":-0.076,"z":0.0},"gearPicPath":"Art/Fix/变速箱齿轮/普通齿轮B"},{"shaftName":"Panel Shaft3","shaftType":2,"targetSpeed":0.0,"hasChildGear":true,"radius":0.4,"gearProp":"","isGearBroken":false,"isDisc":true,"discIdx":0,"shaftPos":{"x":-0.007,"y":-0.898,"z":0.0},"gearPicPath":"Art/Fix/变速箱齿轮/唱片齿轮"}]} \ No newline at end of file diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 0cf46f21f..dbb50d341 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -133,7 +133,7 @@ PlayerSettings: vulkanEnableLateAcquireNextImage: 0 vulkanEnableCommandBufferRecycling: 1 loadStoreDebugModeEnabled: 0 - bundleVersion: 0.2.2.3-20250505-165215 + bundleVersion: 0.2.2.4-20250509-185054 preloadedAssets: - {fileID: 11400000, guid: 0fb2bc2476953fc43a74f0ab8879077c, type: 2} metroInputSource: 0