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

byte[]赋值失败问题 #26

Open
BlueEffie opened this issue Jun 1, 2015 · 0 comments
Open

byte[]赋值失败问题 #26

BlueEffie opened this issue Jun 1, 2015 · 0 comments

Comments

@BlueEffie
Copy link

测试Dll的源码
public class A
{
public void Test()
{
byte[] result = new byte[5]{1,1,1,1,1};
for (int i = 0; i < result.Length; i++)
{
Debug.Log("Before = " + result[i]);
result[i] = 2;
Debug.Log("After = " + result[i]);
}
}
}
在Unity中
public class B : MonoBehaviour
{
void Start()
{
//创建CLRSharp环境
//加载L#模块
//执行构造函数
…………
//调用A类的Test方法
IMethod method0 = wantType.GetMethod("Test",MethodParamList.constEmpty());
method0.Invoke(context, typeObj, null);
}
}

结果A类中Test方法里的result数组中的值没有改变,全部都为1。
用new初始化可以赋值成功,= 赋值失败

我用反射试了一下,没有上面的问题
public class C : MonoBehaviour
{
void Start()
{
TextAsset dll = Resources.Load("CryptoD") as TextAsset;
Assembly ass = Assembly.Load(dll.bytes);
Type type = ass.GetType("A");
Object obj = Activator.CreateInstance(type);
MethodInfo mi = type.GetMethod("Test");
mi.Invoke(obj, null);
}
}

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

1 participant