You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using System;
using System.Collections;
using System.Collections.Generic;
using Puerts;
using UnityEngine;
using System.IO;
using System.Runtime.InteropServices;
public class JSLoader : DefaultLoader // ILoader,IModuleChecker
{
public bool FileExists(string filepath)
{
if (base.FileExists(filepath))
return true;
return File.Exists(filepath);
}
public string ReadFile(string filepath, out string debugpath)
{
if (base.FileExists(filepath))
return base.ReadFile(filepath, out debugpath);
var fileContent = File.ReadAllText(filepath);
debugpath = filepath;
return fileContent;
}
}
//在场景中创建多个GameObject 挂载该文件,
public class TestCrash : MonoBehaviour
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int CBCreateObject();
public JsEnv env;
public static TestCrash instance;
void Awake()
{
if (instance == null)
{
instance = this;
env = new JsEnv(new JSLoader(), 9229);
}
IntPtr pCallback = Marshal.GetFunctionPointerForDelegate<CBCreateObject>(CBCreateTest);
TestCBCrash(pCallback);
}
static int CBCreateTest()
{
Debug.Log("=======CBCreateTest=====");
instance.env.Eval($@"
using System;
using System.Collections;
using System.Collections.Generic;
using Puerts;
using UnityEngine;
using System.IO;
using System.Runtime.InteropServices;
public class JSLoader : DefaultLoader // ILoader,IModuleChecker
{
public bool FileExists(string filepath)
{
if (base.FileExists(filepath))
return true;
return File.Exists(filepath);
}
public string ReadFile(string filepath, out string debugpath)
{
if (base.FileExists(filepath))
return base.ReadFile(filepath, out debugpath);
var fileContent = File.ReadAllText(filepath);
debugpath = filepath;
return fileContent;
}
}
//在场景中创建多个GameObject 挂载该文件,
public class TestCrash : MonoBehaviour
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int CBCreateObject();
public JsEnv env;
public static TestCrash instance;
void Awake()
{
if (instance == null)
{
instance = this;
env = new JsEnv(new JSLoader(), 9229);
}
IntPtr pCallback = Marshal.GetFunctionPointerForDelegate<CBCreateObject>(CBCreateTest);
TestCBCrash(pCallback);
}
static int CBCreateTest()
{
Debug.Log("=======CBCreateTest=====");
instance.env.Eval($@"
daijunli
changed the title
[Unity] Bug:Crash 在C++回调函数到,C#中执行ExecuteModule时如果被加载模块有语法错误Unity会崩溃
[Unity] Bug:Crash C#中执行ExecuteModule时如果被加载模块有语法错误Unity会崩溃
Mar 6, 2024
前置阅读 | Pre-reading
Puer的版本 | Puer Version
2.0.4
Unity的版本 | Unity Version
2021.3.6f1
发生在哪个平台 | Platform
Editor(win)
错误信息 | Error Message
using System;
using System.Collections;
using System.Collections.Generic;
using Puerts;
using UnityEngine;
using System.IO;
using System.Runtime.InteropServices;
public class JSLoader : DefaultLoader // ILoader,IModuleChecker
{
public bool FileExists(string filepath)
{
if (base.FileExists(filepath))
return true;
return File.Exists(filepath);
}
}
//在场景中创建多个GameObject 挂载该文件,
public class TestCrash : MonoBehaviour
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int CBCreateObject();
console.log('============test js env==');
");
}
C++ forTest.dll 的测试代码
![@fv{J2L 82EX3J### 前置阅读 | Pre-reading
Puer的版本 | Puer Version
2.0.4
Unity的版本 | Unity Version
2021.3.6f1
发生在哪个平台 | Platform
Editor(win)
错误信息 | Error Message
using System;
using System.Collections;
using System.Collections.Generic;
using Puerts;
using UnityEngine;
using System.IO;
using System.Runtime.InteropServices;
public class JSLoader : DefaultLoader // ILoader,IModuleChecker
{
public bool FileExists(string filepath)
{
if (base.FileExists(filepath))
return true;
return File.Exists(filepath);
}
}
//在场景中创建多个GameObject 挂载该文件,
public class TestCrash : MonoBehaviour
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int CBCreateObject();
console.log('============test js env==');
");
}
C++ forTest.dll 的测试代码
问题重现 | Bug reproduce
TestPuertsCrash.zip
The text was updated successfully, but these errors were encountered: