Пример #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"));
        }
        /// <summary>
        /// 加载资源的异步委托
        /// </summary>
        /// <param name="name">注意,这个name是FGUI内部组装的纹理全名,例如FUILogin_atlas0</param>
        /// <param name="extension"></param>
        /// <param name="type"></param>
        /// <param name="item"></param>
        private static async void LoadPackageInternalAsync(string name, string extension, System.Type type, PackageItem item)
        {
            Texture texture =
                await ResourcesComponent.Instance.LoadAssetAsync <Texture>(ABPathUtilities.GetFGUIResPath(name, extension));

            item.owner.SetItemAsset(item, texture, DestroyMethod.Unload);
        }
        public async ETTask AddPackageAsync(string type)
        {
            if (this.packages.ContainsKey(type))
            {
                return;
            }

            TextAsset desTextAsset =
                await ResourcesComponent.Instance.LoadAssetAsync <TextAsset>(ABPathUtilities.GetFGUIDesPath($"{type}_fui"));

            packages.Add(type, UIPackage.AddPackage(desTextAsset.bytes, type, LoadPackageInternalAsync));
        }
        //加载声音
        private async ETTask <SoundData> LoadSound(string soundName)
        {
            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();

            if (!abSounds.ContainsKey(soundName) || abSounds[soundName] == null)
            {
                abSounds.Add(soundName,
                             UnityEngine.Object.Instantiate(
                                 (resourcesComponent.LoadAsset <GameObject>(ABPathUtilities.GetSoundPath("Sound")))
                                 .GetTargetObjectFromRC <GameObject>(soundName))
                             .GetComponent <SoundData>());
            }

            return(abSounds[soundName]);
        }
Пример #5
0
        public void RemovePackage(string type)
        {
            UIPackage package;

            if (packages.TryGetValue(type, out package))
            {
                var p = UIPackage.GetByName(package.name);

                if (p != null)
                {
                    UIPackage.RemovePackage(package.name);
                }

                packages.Remove(package.name);
            }

            if (!Define.ResModeIsEditor)
            {
                Game.Scene.GetComponent <ResourcesComponent>().UnLoadAsset(ABPathUtilities.GetFGUIDesPath($"{type}_fui"));
                Game.Scene.GetComponent <ResourcesComponent>().UnLoadAsset(ABPathUtilities.GetFGUIResPath($"{type}_atlas0"));
            }
        }
Пример #6
0
        public void Awake()
        {
            Type[] types = typeof(NodeType).Assembly.GetTypes();
            foreach (Type type in types)
            {
                if (type.IsSubclassOf(typeof(NP_NodeDataBase)) || type.IsSubclassOf(typeof(NP_ClassForStoreAction)) ||
                    type.IsSubclassOf(typeof(BuffNodeDataBase)) || type.IsSubclassOf(typeof(BuffDataBase)) ||
                    type.IsSubclassOf(typeof(ListenBuffEvent_Normal)) || type.IsSubclassOf(typeof(NP_DataSupportorBase)))
                {
                    BsonClassMap.LookupClassMap(type);
                }
            }

            BsonClassMap.LookupClassMap(typeof(NP_BBValue_Int));
            BsonClassMap.LookupClassMap(typeof(NP_BBValue_Bool));
            BsonClassMap.LookupClassMap(typeof(NP_BBValue_Float));
            BsonClassMap.LookupClassMap(typeof(NP_BBValue_String));
            BsonClassMap.LookupClassMap(typeof(NP_BBValue_Vector3));
            BsonClassMap.LookupClassMap(typeof(NP_BBValue_Long));
            BsonClassMap.LookupClassMap(typeof(NP_BBValue_List_Long));
#if SERVER
            DirectoryInfo directory = new DirectoryInfo(NPDataPath);
            FileInfo[]    fileInfos = directory.GetFiles();

            foreach (var fileInfo in fileInfos)
            {
                byte[] mfile = File.ReadAllBytes(fileInfo.FullName);

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

                try
                {
                    NP_DataSupportor MnNpDataSupportor = BsonSerializer.Deserialize <NP_DataSupportor>(mfile);

                    Log.Info($"反序列化行为树:{fileInfo.FullName}完成");

                    NpRuntimeTreesDatas.Add(MnNpDataSupportor.RootId, MnNpDataSupportor);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
#else
            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();
            GameObject         skillConfigs       = resourcesComponent.LoadAsset <GameObject>(ABPathUtilities.GetSkillConfigPath("SkillConfigs"));
            foreach (var referenceCollectorData in skillConfigs.GetComponent <ReferenceCollector>().data)
            {
                TextAsset textAsset = skillConfigs.GetTargetObjectFromRC <TextAsset>(referenceCollectorData.key);

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

                try
                {
                    NP_DataSupportor MnNpDataSupportor = BsonSerializer.Deserialize <NP_DataSupportor>(textAsset.bytes);

                    Log.Info($"反序列化行为树:{referenceCollectorData.key}完成");

                    this.m_NpRuntimeTreesDatas.Add(MnNpDataSupportor.NpDataSupportorBase.NPBehaveTreeDataId, MnNpDataSupportor);
                }
                catch (Exception e)
                {
                    Log.Error(e);
                    throw;
                }
            }
#endif
        }
        private async ETVoid StartToLoadIcon()
        {
            GameObject HeroAvatars = Game.Scene.GetComponent <ResourcesComponent>().LoadAsset <GameObject>(ABPathUtilities.GetTexturePath("HeroAvarars"));
            Texture2D  tex         = HeroAvatars.GetTargetObjectFromRC <Sprite>("Darius").texture;

            if (tex != null)
            {
                onExternalLoadSuccess(new NTexture(tex));
            }
            else
            {
                onExternalLoadFailed();
            }
        }
Пример #8
0
        /// <summary>
        /// 准备英雄资源
        /// </summary>
        /// <param name="heroType"></param>
        private static void PrepareHeroRes(string heroType)
        {
            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();
            GameObject         bundleGameObject   = resourcesComponent.LoadAsset <GameObject>(ABPathUtilities.GetUnitPath("Unit"));
            GameObject         prefab             = bundleGameObject.GetTargetObjectFromRC <GameObject>(heroType);

            Game.Scene.GetComponent <GameObjectPool>().Add(heroType, prefab);
        }
Пример #9
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);
     }
 }
Пример #10
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
        }