InjectFix icon indicating copy to clipboard operation
InjectFix copied to clipboard

新增类使用报错

Open shahdza opened this issue 5 years ago • 4 comments

` 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)

shahdza avatar Dec 01 '20 08:12 shahdza

有可能是没有方法的原因,你加个方法试试?

chexiongsheng avatar Dec 02 '20 11:12 chexiongsheng

老哥解决了吗 我也出现了这样的问题。往新增加的类里加方法也没用

chenhuomain avatar Dec 10 '20 07:12 chenhuomain

(thisAdd as ColorClass)这导致的,还不支持强转到新类

chexiongsheng avatar Dec 10 '20 07:12 chexiongsheng

请问目前阶段有什么解决方法? 在我用新类NewClass的时候 ,我定义了List 我该怎么从这个列表里拿到NewClass的对象呢

chenhuomain avatar Dec 11 '20 02:12 chenhuomain