From 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 11 五月 2026 16:20:37 +0800
Subject: [PATCH] Merge branch 'master' into h5version
---
Main/System/Message/ImgAnalysis.cs | 55 ++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/Main/System/Message/ImgAnalysis.cs b/Main/System/Message/ImgAnalysis.cs
index 05c8164..1b03ee0 100644
--- a/Main/System/Message/ImgAnalysis.cs
+++ b/Main/System/Message/ImgAnalysis.cs
@@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
+using Cysharp.Threading.Tasks;
using UnityEngine;
public class ImgAnalysis : TRichAnalysis<ImgAnalysis>
@@ -12,7 +13,7 @@
private RichTextMgr.ImgInfo presentImgInfo = null;
- public override string Analysis(string val, bool IsRich)
+ public override async UniTask<string> Analysis(string val, bool IsRich)
{
if (!Img_Regex.IsMatch(val))
{
@@ -30,7 +31,7 @@
presentImgInfo = imgInfo;
m_StringBuilder.Append(val.Substring(index, match.Index - index));
- AnalysisSplitEvent(match.Groups[1].Value);
+ await AnalysisSplitEvent(match.Groups[1].Value);
if (IsRich)
{
@@ -92,7 +93,7 @@
return val;
}
- private void AnalysisSplitEvent(string val)
+ private async UniTask AnalysisSplitEvent(string val)
{
string[] array = GetSplitEvent(val);
if (array.Length > 0)
@@ -102,7 +103,7 @@
AnalysisSplitData(split_event);
}
}
- LoadSprite();
+ await LoadSprite();
}
private void AnalysisSplitData(string val)
@@ -189,18 +190,58 @@
m_StringBuilder.Append("/></color>");
}
- private void LoadSprite()
+ private async UniTask LoadSprite()
{
if (presentImgInfo.IsFace) return;
if (IconConfig.isInit)
{
if (!string.IsNullOrEmpty(presentImgInfo.folderName))
{
- presentImgInfo.sprite = UILoader.LoadSprite(presentImgInfo.folderName, presentImgInfo.spriteName);
+ presentImgInfo.sprite = await UILoader.LoadSpriteAsync(presentImgInfo.folderName, presentImgInfo.spriteName);
}
else
{
- presentImgInfo.sprite = UILoader.LoadSprite(presentImgInfo.spriteName);
+ presentImgInfo.sprite = await UILoader.LoadSpriteAsync(presentImgInfo.spriteName);
+ }
+ }
+
+ if (presentImgInfo.sprite != null)
+ {
+ RichText text = RichTextMgr.Inst.presentRichText;
+ if (text != null)
+ {
+ if (text.LockImgSize)
+ {
+ presentImgInfo.width = presentImgInfo.height = text.fontSize;
+ return;
+ }
+ else if (text.ModifyImgSiez)
+ {
+ presentImgInfo.width = text.ModifyImgWidth;
+ presentImgInfo.height = text.ModifyImgHeight;
+ return;
+ }
+ }
+ if (presentImgInfo.scale != 1f)
+ {
+ presentImgInfo.width = presentImgInfo.sprite.rect.width * presentImgInfo.scale;
+ presentImgInfo.height = presentImgInfo.sprite.rect.height * presentImgInfo.scale;
+ }
+ }
+ }
+
+ private async UniTask LoadSpriteAsync()
+ {
+ if (presentImgInfo.IsFace) return;
+ if (IconConfig.isInit)
+ {
+ if (!string.IsNullOrEmpty(presentImgInfo.folderName))
+ {
+ presentImgInfo.sprite = await UILoader.LoadSpriteAsync(presentImgInfo.folderName, presentImgInfo.spriteName);
+ }
+ else
+ {
+ presentImgInfo.sprite = await UILoader.LoadSpriteAsync(presentImgInfo.spriteName);
}
}
--
Gitblit v1.8.0