yyl
2026-05-11 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96
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);
            }
        }