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

[Unity] 2021下生成UnityEngine.Screen报错 #758

Closed
lsx1994 opened this issue Apr 13, 2022 · 4 comments
Closed

[Unity] 2021下生成UnityEngine.Screen报错 #758

lsx1994 opened this issue Apr 13, 2022 · 4 comments
Assignees

Comments

@lsx1994
Copy link

lsx1994 commented Apr 13, 2022

Unity版本:2021.3.0f1c1
问题描述:升级前可以正常运行,升级后报错。

1.自动生成代码错误

log:
Assets\Gen\UnityEngine_Screen_Wrap.cs(198,78): error CS1615: Argument 1 may not be passed with the 'ref' keyword
code:
var result = UnityEngine.Screen.MoveMainWindowTo(ref Arg0, Arg1);
这个问题手动删除ref可解决。

2.加载init.mjs失败

log:

Exception: puerts/init.mjs:1: Error: resolve module puerts/init.mjs error: Object reference not set to an instance of an object
Error: resolve module puerts/init.mjs error: Object reference not set to an instance of an object
    at puerts/init.mjs:1:7
Puerts.JsEnv.ExecuteModule (System.String filename) (at Assets/Puerts/Runtime/Src/JsEnv.cs:256)
Puerts.JsEnv..ctor (Puerts.ILoader loader, System.Int32 debugPort, System.IntPtr externalRuntime, System.IntPtr externalContext) (at Assets/Puerts/Runtime/Src/JsEnv.cs:166)
Puerts.JsEnv..ctor (Puerts.ILoader loader, System.Int32 debugPort) (at Assets/Puerts/Runtime/Src/JsEnv.cs:68)
PuertsMgr.Init () (at Assets/Scripts/Engine/Puerts/PuertsMgr.cs:15)
GameLanch.Start () (at Assets/Scripts/GameLanch.cs:26)

code:

public void Init() {
        loader = new Loader(Path.Combine(Application.streamingAssetsPath,"JavaScript"));
        jsEnv = new JsEnv(loader);        // 实例化 js 虚拟机 
#if UNITY_EDITOR
        jsEnv.WaitDebuggerAsync(); // 启用调试
#endif
    }
@zombieyang zombieyang self-assigned this Apr 14, 2022
@zombieyang
Copy link
Contributor

问题1,测试了在1.2.x也有,不是1.3.2导致的。

问题2,如果DefaultLoader没问题,你自己写的Loader有问题,那还是先从你自己Loader里的逻辑开始排查

@zombieyang zombieyang changed the title [Unity] 升级插件到1.3.2报错 [Unity] 2021下生成UnityEngine.Screen报错 Apr 15, 2022
@lsx1994
Copy link
Author

lsx1994 commented Apr 15, 2022

问题1确认是升级Unity版本引起的。
问题2我自己再查查看,我测试了一下最新的demo用这个Unity版本没问题

@lsx1994 lsx1994 closed this as completed Apr 15, 2022
@zombieyang
Copy link
Contributor

问题1我这边查一下

@zombieyang zombieyang reopened this Apr 15, 2022
@lsx1994
Copy link
Author

lsx1994 commented Apr 15, 2022

问题2 我自己写的Loader把基类改成DefaultLoader就可以了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants