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

对枚举类型进行实现扩展函数会patch失败 #9

Open
moyubing0514 opened this issue Sep 28, 2019 · 0 comments
Open

对枚举类型进行实现扩展函数会patch失败 #9

moyubing0514 opened this issue Sep 28, 2019 · 0 comments

Comments

@moyubing0514
Copy link

使用枚举类型扩展函数会导致E:CSharpException:ArgumentNullException: Value cannot be null 报错.
无法patch的C#代码如下:

using UnityEngine;
public class Test : MonoBehaviour
{
void Start() {
TestEnum.A.TestFunc();
}
}
public enum TestEnum {
A,
B,
C
}
public static class TestStatic {
public static void TestFunc(this TestEnum type) {
Debug.Log(type.ToString());
}
}

修改成常规静态方法不再报错,修改后如下:
using UnityEngine;
public class Test : MonoBehaviour
{
void Start() {
TestStatic.TestFunc(TestEnum.A);
}
}
public enum TestEnum {
A,
B,
C
}
public static class TestStatic {

public static void TestFunc(TestEnum type) {
    Debug.Log(type.ToString());
}

}

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