示例#1
0
        public void LoadHotfixAssembly()
        {
            GameObject code = Game.Scene.GetComponent <ResourcesComponent>().LoadAsset <GameObject>(ABPathUtilities.GetNormalConfigPath("Code"));

            byte[] assBytes = code.GetTargetObjectFromRC <TextAsset>("Hotfix.dll").bytes;
            byte[] pdbBytes = code.GetTargetObjectFromRC <TextAsset>("Hotfix.pdb").bytes;

#if ILRuntime
            Log.Debug($"当前使用的是ILRuntime模式");
            this.appDomain = new ILRuntime.Runtime.Enviorment.AppDomain();

            this.dllStream = new MemoryStream(assBytes);
            this.pdbStream = new MemoryStream(pdbBytes);
            this.appDomain.LoadAssembly(this.dllStream, this.pdbStream, new Mono.Cecil.Pdb.PdbReaderProvider());

            this.start = new ILStaticMethod(this.appDomain, "ETHotfix.Init", "Start", 0);

            this.hotfixTypes = this.appDomain.LoadedTypes.Values.Select(x => x.ReflectionType).ToList();
#else
            Log.Debug($"当前使用的是Mono模式");

            this.assembly = Assembly.Load(assBytes, pdbBytes);

            Type hotfixInit = this.assembly.GetType("ETHotfix.Init");
            this.start = new MonoStaticMethod(hotfixInit, "Start");

            this.hotfixTypes = this.assembly.GetTypes().ToList();
#endif

            Game.Scene.GetComponent <ResourcesComponent>().UnLoadAsset(ABPathUtilities.GetNormalConfigPath("Code"));
        }
示例#2
0
 public static string GetText(string key)
 {
     try
     {
         GameObject config    = Game.Scene.GetComponent <ResourcesComponent>().LoadAsset <GameObject>(ABPathUtilities.GetNormalConfigPath("Config"));
         string     configStr = config.GetTargetObjectFromRC <TextAsset>(key).text;
         return(configStr);
     }
     catch (Exception e)
     {
         throw new Exception($"load config file fail, key: {key}", e);
     }
 }
示例#3
0
        public void Awake()
        {
#if SERVER
            byte[] mfile = File.ReadAllBytes("../Config/HeroBaseDatas/AllHeroDatas.bytes");
            this.AllHeroBaseDataDic = BsonSerializer.Deserialize <HeroDataSupportor>(mfile);
#else
            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();
            GameObject         heroDataConfigs    = resourcesComponent.LoadAsset <GameObject>(ABPathUtilities.GetNormalConfigPath("HeroDataConfigs"));
            foreach (var referenceCollectorData in heroDataConfigs.GetComponent <ReferenceCollector>().data)
            {
                TextAsset textAsset = heroDataConfigs.GetTargetObjectFromRC <TextAsset>(referenceCollectorData.key);

                if (textAsset.bytes.Length == 0)
                {
                    Log.Info("没有读取到文件");
                }

                this.AllHeroBaseDataDic = BsonSerializer.Deserialize <HeroDataSupportor>(textAsset.bytes);
            }
#endif
        }