Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

脚本挂载到TMP时导致小游戏所有脚本失效 #912

Closed
Rice00 opened this issue Dec 5, 2024 · 1 comment
Closed

脚本挂载到TMP时导致小游戏所有脚本失效 #912

Rice00 opened this issue Dec 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Rice00
Copy link

Rice00 commented Dec 5, 2024

描述Bug

当我将一个脚本挂载到特定Textmesh Pro上时(其余的不会导致这个问题),会导致微信转换的小游戏所有的脚本失效,所有挂载的脚本不再工作,在我的场景中只有特定两个TMP挂载脚本会导致转换的小游戏脚本失效。

以下是我挂载的脚本,用于监听GameSystem发出的调用WX.getWXFont()方法产生回调所更新字体的事件。

    private void Awake()
    {
        GameSystem.Instance.onUpdateFont += onFontUpdate;
    }

    private void onFontUpdate(Font font)
    {
        WX.WriteLog("字体更新");
        TextMeshProUGUI text = GetComponent<TextMeshProUGUI>();
        TMP_FontAsset tmpFont = TMP_FontAsset.CreateFontAsset(font);
        text.font = tmpFont;
    }

这是我在GameSystem中更新字体的方法,此方法在initSDK的回调中调用,initSDK在awake中调用

   private void initFont()
    {
        WX.WriteLog("开始初始化字体");
        WX.GetWXFont(fontFallback, (font) =>
        {
            GameFont = font;
            WX.WriteLog("字体初始化成功 当前有:" + onUpdateFont.GetInvocationList().Length);
            onUpdateFont?.Invoke(GameFont);
            //TODO temporary
            debugPanel.updateFont(GameFont);
        });
    }

@#911 (comment)
此issue和本issue同时发生

运行环境

Windows11/2022.3.14f1c1/minigame.202411141147/PackageManager Git/WebGL
测试平台Android,机型Redmi K70, Wechat Ver.8.0.53
@Rice00 Rice00 added the bug Something isn't working label Dec 5, 2024
@Rice00
Copy link
Author

Rice00 commented Dec 6, 2024

我的问题

@Rice00 Rice00 closed this as completed Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant