public static void OpenUIWindowDebugPlane() { if (null == DebugPlaneRes) { DebugPlaneRes = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, PrefabGUID, true); GameObject go = null; if (!ResNode.isNullOrEmpty(DebugPlaneRes)) { go = DebugPlaneRes.InstanceMainRes(); if (go) { go.transform.SetParent(UISystem.Instance.transform); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; } } } if (m_Instance) { m_Instance.gameObject.SetActive(true); m_Instance.transform.SetParent(UISystem.Instance.transform); m_Instance.transform.localPosition = Vector3.zero; m_Instance.transform.localScale = Vector3.one; } }
private static void OnSceneLoadFinish(string sceneName) { isHaveData = false; //如果是非吃鸡场景,卸载. if (GameLogicAPI.getCurGameMode() != Game_ManagedDef.EGameMode.EGM_MCAMP) { AssetBundleManager.DeleteAssets(ref SafeZoneEffectRes, true); SafeZoneEffectInstance = null; return; } if (null == SafeZoneEffectRes) { SafeZoneEffectRes = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, SafeZoneEffectGUID, true); if (!ResNode.isNullOrEmpty(SafeZoneEffectRes)) { SafeZoneEffectInstance = SafeZoneEffectRes.InstanceMainRes <Effect.EffectNode>(); if (SafeZoneEffectInstance) { SafeZoneEffectInstance.Init(); SafeZoneEffectInstance.StopEffect(); SafeZoneTransform = SafeZoneEffectInstance.transform; SafeZoneTransform.SetParent(EntityFactory.EffectGroup.transform); GenerateZoneMaterial(SafeZoneEffectInstance); } } } if (SafeZoneEffectInstance) { SafeZoneEffectInstance.StopEffect(); } }
public void LoadOtherTex() { foreach (SceneMaterialConfig r in ConfigDataList) { if (!r.SharedMaterial) { if (!bPreaLoaded) { currPreLoadedTexCount++; } continue; } foreach (SceneTextureConfigData rt in r.TextureConfigList) { ResNode nod = null; //主贴图是不会释放的,先看看是不是主贴图,如果是主贴图的话,看看是不是加载了,是的话,就跳过 bool isMainTex = rt.ShaderKeyWordName.Equals(MainTexKeyWorld); if (isMainTex) { continue; } //如果是永远不优化内存,也只会加载一次,后面就不加载了 OtherLoadedResTable.TryGetValue(rt, out nod); if (null != nod) { continue; } nod = AssetBundleManager.GetAssetsAsync(AssetType.Asset_Texture, rt, this, r); if (!ResNode.isNullOrEmpty(nod)) { OtherLoadedResTable.Add(rt, nod); //不优化内存的需要增加一下引用.避免多个引用删除 if (AlwaysUnOptimitzedMemory) { if (!UnOptimitzedMaterials.ContainsKey(r.SharedMaterial)) { UnOptimitzedMaterials.Add(r.SharedMaterial, 1); } else { UnOptimitzedMaterials[r.SharedMaterial]++; } } } else { if (!bPreaLoaded) { currPreLoadedTexCount++; } } } } }
public void Awake() { isOnGameRuning = true; m_WindowHwnd = GameLogicAPI.getMainWindHwnd(); if (!Application.isEditor) { GameLogicAPI.SetWindowText(Initialize.m_WindowHwnd, "泰坦-大地之子,勇往直前"); } InitDoTween(); GameLogicAPI.OpenLog(); if (AssetBundleManager.isVaild) { LoadingWaitngResNode = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, "fa32d80346317d445bf6bdd4f1b4c5da", true); if (!ResNode.isNullOrEmpty(LoadingWaitngResNode)) { LoadingWaitngResNode.InstanceMainRes(); } } DontDestroyOnLoad(gameObject); Type[] types = new Type[] { typeof(Trace), }; CreateModulesSync(types); if (Time.timeScale < 0.01) { Time.timeScale = 1f; } mainCam = Camera.main; Instance = this; myTransform = this.transform; SoliderTarget = myTransform.FindChild("SoldierTarget").gameObject; Hero_Camera = Initialize.mainCam.gameObject; TargetFrame = myTransform.FindChild("TargetFrame").gameObject; Second_Camera = myTransform.FindChild("Second_Camera").gameObject; SecondTarget = Second_Camera.transform.FindChild("SecondTarget").gameObject; CamInitPos = Hero_Camera.transform.position; CamInitQua = Hero_Camera.transform.rotation; SetState(InitializeState.Init); SceneManager.RegisterSceneLoadFinishEvent(SceneLoadFinish); SceneManager.RegisterSceneLoadStartEvent(SceneLoadStart); SceneResInfoManager.RegisterActiveSceneChangedEvent(ActiveSceneChanged); UISystem.OnResolutionChanged += DoMouseLockInModeType; //将显示层配置文档初始化提前避免启用多线程时配置文档未初始化 //ViewConfigManager.Init(); }
private void DeleteFloatingAssets() { if (!ResNode.isNullOrEmpty(WingAssets)) { WingAssets.DestroyInstanceRes(ref wingGO); AssetBundleManager.DeleteAssets(ref WingAssets, false); wingGO = null; wingAnimator = null; } }
public void Init(Transform CacheParent) { if (stage != loadingStage.Stage_Finish) { return; } if (ResNode.isNullOrEmpty(prefabResNode) || !effectConfig) { return; } currCahceTransform = CacheParent; isValid = true; }
/// <summary> /// 节约内存,别乱调用。 /// </summary> /// <param name="res"></param> public static void SaveMemory(ResNode res) { if (!isOnRunTimeMode) { return; } if (ResNode.isNullOrEmpty(res)) { return; } if (res.assetType != AssetType.Asset_Prefab) { return; } res.SaveMemory(); }
public void LoadMainTex() { foreach (SceneMaterialConfig r in ConfigDataList) { if (!r.SharedMaterial) { if (!bPreaLoaded) { currPreLoadedTexCount++; } continue; } foreach (SceneTextureConfigData rt in r.TextureConfigList) { if (rt.ShaderKeyWordName.Equals(MainTexKeyWorld)) { ResNode nod = null; //主贴图是不会释放的,先看看是不是主贴图,如果是主贴图的话,看看是不是加载了,是的话,就跳过 MainTexLoadedResTable.TryGetValue(rt, out nod); if (null != nod) { continue; } nod = AssetBundleManager.GetAssets(AssetType.Asset_Texture, rt); if (!ResNode.isNullOrEmpty(nod)) { ResLoadCallBack(rt, nod, r); MainTexLoadedResTable.Add(rt, nod); } else { if (!bPreaLoaded) { currPreLoadedTexCount++; } } } } } }
/// <summary> /// 不优化内存 /// </summary> public void UnOptimitzedMemory() { //可见才能不优化 if (!bOptimitzedMenory || bOptimitzedRendering || AlwaysUnOptimitzedMemory) { return; } foreach (SceneMaterialConfig r in ConfigDataList) { if (!r.SharedMaterial) { continue; } if (!UnOptimitzedMaterials.ContainsKey(r.SharedMaterial)) { UnOptimitzedMaterials.Add(r.SharedMaterial, 1); } else { UnOptimitzedMaterials[r.SharedMaterial]++; } foreach (SceneTextureConfigData rt in r.TextureConfigList) { if (!rt.ShaderKeyWordName.Equals(MainTexKeyWorld)) { ResNode re = null; if (!OtherLoadedResTable.ContainsKey(rt)) { re = AssetBundleManager.GetAssetsAsync(AssetType.Asset_Texture, rt, this, r); if (!ResNode.isNullOrEmpty(re)) { OtherLoadedResTable.Add(rt, re); } } } } } bOptimitzedMenory = false; }
public void Clear() { foreach (LightingEffectResHandleInstance instance in m_AllInstanceNode) { GameObject temp = instance.effectPrefab; if (!ResNode.isNullOrEmpty(prefabResNode)) { prefabResNode.DestroyInstanceRes(ref temp); } instance.Clear(); } m_CacheList.Clear(); m_AllInstanceNode.Clear(); effectConfig = null; prefabResNode = null; ReferenceCount = 0; isValid = false; stage = loadingStage.Stage_Invalid; currCacheTime = 0.0f; }
private void LoadTerrain(SceneTerrainConfigData terrainConfig) { if (null == terrainConfig) { return; } if (string.IsNullOrEmpty(terrainConfig.TerrainGUID)) { return; } ResNode terrainResNode = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, terrainConfig.TerrainGUID, true); if (ResNode.isNullOrEmpty(terrainResNode)) { Debug.LogError("地形丢失:" + terrainConfig.TerrainGUID); return; } Terrain terrain = terrainResNode.InstanceMainRes <Terrain>(); terrain.transform.position = terrainConfig.TerrainPos; TerrainResNodeList.Add(terrainResNode); TerrainList.Add(terrain); terrain.transform.SetParent(UnityTerrainRoot.transform); }
public void Start() { if (!CheckMultclient()) { Application.Quit(); return; } if (!CkeckUpdateOk()) { Application.Quit(); return; } Instance = this; Initialize.m_WindowHwnd = GameLogicAPI.getMainWindHwnd(); AssetBundleManager.Init(); UIResNode = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, "f8aafccc7fff6e34490e09b186458dd8", true); if (ResNode.isNullOrEmpty(UIResNode)) { Debug.LogError("找不到性能检测UI资源,以最低配置运行"); if (AssetBundleManager.isCanLoadLevel(LoginSceneName)) { AssetBundleManager.LoadLevel(LoginSceneName); } return; } flowShareData.CheckUI = UIResNode.InstanceMainRes <PerformanceCheck_UI>(); if (!flowShareData.CheckUI) { Debug.LogError("找不到性能检测UI,以最低配置运行"); if (AssetBundleManager.isCanLoadLevel(LoginSceneName)) { AssetBundleManager.LoadLevel(LoginSceneName); } return; } ImageEffects.ImageEffectManager.API_ResetSceneBrightness(); FlowTable.Add(CheckFlow.HardWareSupport, new PerformanceCheckFlow_HardWareSupport()); FlowTable.Add(CheckFlow.GeometricRender, new PerformanceCheckFlow_RenderingLevel()); FlowTable.Add(CheckFlow.Finish, new PerformanceCheckFlow_Finish()); ViewConfigManager.SetDefaultViewConfigPath(); if (flowShareData.CheckUI) { flowShareData.CheckUI.Init(); } //本地已经有这个配置了,直接进游戏 if (GetPerformanceCheckVersion() == currPerformanceCheckVersion) { if (AssetBundleManager.isCanLoadLevel(LoginSceneName)) { AssetBundleManager.LoadLevel(LoginSceneName); } } else { InitData(); if (flowShareData.CheckUI) { flowShareData.CheckUI.StartCheck(); } ChangeFlow(CheckFlow.HardWareSupport); StartCoroutine(RunPerformanceCheck()); } }
public static void Init() { if (isVaild) { return; } //文件只能上一个,一样会阻塞加载线程 MinUpLoadAssetsFileAsyncRequestCount = 1; MaxUpLoad_Assets_AsyncRequestClip = Mathf.Min(4, SystemInfo.processorCount); enabledUnionDependenices = enabledUnionDependenices && !File.Exists("disabledUnionDependenices.txt"); MaxUpLoad_Assets_AsyncRequestClip = File.Exists("uploadrequestsingle.txt") ? 0.0001f : MaxUpLoad_Assets_AsyncRequestClip; OpenRunTime = OpenRunTime || File.Exists("openruntime.txt"); enabledAsyncLoadAssetFile = enabledAsyncLoadAssetFile && !File.Exists("disableasyncloadassetfile.txt"); m_bEnabled = CheckDiskFreeSpace(); if (!m_bEnabled) { Clear(); return; } ClearResNodeTempData(); ClearAssetFileTempData(); LoadAllAssetBundleConfigData(); LoadShaders(); InitAssetBundleThread(); InitScene(); LoadPrefabConfig(); InitUIRes(); LoadFontRes(); LoadCommonAssets(); if (!HostGameObject) { HostGameObject = new GameObject(); HostGameObject.name = "AssetBundleManager"; HostGameObject.transform.position = Vector3.zero; HostGameObject.transform.rotation = Quaternion.identity; HostGameObject.transform.localScale = Vector3.one; MonoInstance = HostGameObject.AddComponent <AssetBundleManager>(); UnityEngine.Object.DontDestroyOnLoad(HostGameObject); } ResNode res = null; CommonDissolveTextureConfigData = new ResConfigData(); CommonDissolveTextureConfigData.AssetBundleName = "texture/commonartist/unitydefaultresources/texture.texture"; CommonDissolveTextureConfigData.AssetGUID = "d5fb8ec7c6ae5334eabcbc04e73f44ee"; CommonDissolveTextureConfigData.AssetName = "CommonDissolveMap"; CommonDissolveTextureConfigData.AssetSize_X = 256; CommonDissolveTextureConfigData.AssetSize_Y = 256; CommonDissolveTextureConfigData.fromReference = false; res = GetTextureResource(CommonDissolveTextureConfigData); if (!ResNode.isNullOrEmpty(res)) { CommonDissloveTexture = res.ConvertRes <Texture>(); } CommonBlack_AlphaZeroTextureConfigData = new ResConfigData(); CommonBlack_AlphaZeroTextureConfigData.AssetBundleName = "texture/commonartist/unitydefaultresources/texture.texture"; CommonBlack_AlphaZeroTextureConfigData.AssetGUID = "2a8ce53528d8ac348af0de443cafb77c"; CommonBlack_AlphaZeroTextureConfigData.AssetName = "BlackTexture_ZeroAlpha"; CommonBlack_AlphaZeroTextureConfigData.AssetSize_X = 256; CommonBlack_AlphaZeroTextureConfigData.AssetSize_Y = 256; CommonBlack_AlphaZeroTextureConfigData.fromReference = false; res = GetTextureResource(CommonBlack_AlphaZeroTextureConfigData); if (!ResNode.isNullOrEmpty(res)) { CommonBlack_AlphaZeroTexture = res.ConvertRes <Texture>(); } if (!CommonDissloveTexture) { Debug.LogWarning("找不到CommonDisslove溶解贴图,使用白色贴图代替"); CommonDissloveTexture = Texture2D.whiteTexture; } if (!CommonBlack_AlphaZeroTexture) { Debug.LogWarning("找不到CommonBlack_AlphaZeroTexture溶解贴图,使用黑色色贴图代替"); CommonBlack_AlphaZeroTexture = Texture2D.blackTexture; } }
/// <summary> /// 资源加载回调 /// </summary> /// <param name="cof"></param> /// <param name="res"></param> /// <param name="UserDataObj"></param> public void ResLoadCallBack(ResConfigData cof, ResNode res, System.Object UserDataObj) { SceneTextureConfigData rt = cof as SceneTextureConfigData; SceneMaterialConfig r = UserDataObj as SceneMaterialConfig; if (null == rt) { return; } if (!bPreaLoaded) { currPreLoadedTexCount++; } //加载资源失败了,回调为null,计数器也要+1 if (ResNode.isNullOrEmpty(res)) { return; } if (!r.SharedMaterial) { return; } Texture tex = res.ConvertRes <Texture>(); Material instanceFadeMat = null; Material orginalInstanceMat = null; if (currFadeMatTable != null && currFadeMatTable.ContainsKey(r.SharedMaterial)) { instanceFadeMat = currFadeMatTable[r.SharedMaterial]; } Orginal_AlphaInstanceTable.TryGetValue(r.SharedMaterial, out orginalInstanceMat); if (instanceFadeMat) { instanceFadeMat.SetTexture(rt.ShaderKeyWordName, tex); } if (orginalInstanceMat) { orginalInstanceMat.SetTexture(rt.ShaderKeyWordName, tex); } r.SharedMaterial.SetTexture(rt.ShaderKeyWordName, tex); if (rt.ShaderKeyWordVariantName.Count != 0) { foreach (string variant in rt.ShaderKeyWordVariantName) { if (instanceFadeMat) { instanceFadeMat.EnableKeyword(variant); } if (orginalInstanceMat) { orginalInstanceMat.EnableKeyword(variant); } r.SharedMaterial.EnableKeyword(variant); } } }