InjectFix
InjectFix copied to clipboard
新增类使用报错
` using UnityEngine; using UnityEngine.UI;
namespace ClientX2HotFix
{
// 新增类
[IFix.Interpret]
public class ColorClass
{
public Color colorRed = new Color(1, 0, 0);
}
public class Test : MonoBehaviour
{
private object thisAdd;
Image image;
[IFix.Patch]
void Start()
{
// 原生代码
image.color = new Color(0, 0, 0);
// patch代码
thisAdd = new ColorClass();
image = GetComponent<Image>();
image.color = (thisAdd as ColorClass).colorRed;
}
}
}
`
报错信息: Exception: can not load type [ClientX2HotFix.ColorClass, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null] IFix.Core.PatchManager.Load (System.IO.Stream stream, Boolean checkNew) GameManager.LoadIFix () (at Assets/Scripts/GameManager.cs:37) GameManager.Awake () (at Assets/Scripts/GameManager.cs:16)
有可能是没有方法的原因,你加个方法试试?
老哥解决了吗 我也出现了这样的问题。往新增加的类里加方法也没用
(thisAdd as ColorClass)这导致的,还不支持强转到新类
请问目前阶段有什么解决方法? 在我用新类NewClass的时候 ,我定义了List