// Use this for initialization override public void Start() { //从 prefabPathArr 列表 获取所有的 prefab 的光照信息 for (int i = 0; i < prefabPathArr.Length; i++) { string prefabLightmapDataABPath = SceneLightmapUtil.GetPrefabLightmapDataABPath(prefabPathArr[i]); AssetBundle assetBundle; if (abPathDic.ContainsKey(prefabLightmapDataABPath)) { assetBundle = abPathDic[prefabLightmapDataABPath]; } else { assetBundle = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/" + prefabLightmapDataABPath); abPathDic.Add(prefabLightmapDataABPath, assetBundle); } string[] allAssetNames = assetBundle.GetAllAssetNames(); GameObjectLightmapData gameObjectLightmapData = assetBundle.LoadAsset <GameObjectLightmapData>(allAssetNames[0]); //加入路径列表 AddLightMap(gameObjectLightmapData, sceneName, lmType); } LoadLightMap(); }
public void AddLightMap(GameObjectLightmapData gameObjectLightmapData, string sceneName, string lmtype = "") { for (int i = 0; i < gameObjectLightmapData.renderersLightmapDataList.Count; i++) { RenderersLightmapData renderersLightmapData = gameObjectLightmapData.renderersLightmapDataList[i]; string texAssetBundlePath = SceneLightmapUtil.GetLightmapTexABPath(sceneName, renderersLightmapData.m_lightmapIndex, lmtype); if (!assetBundlePathIndexDic.ContainsKey(renderersLightmapData.m_lightmapIndex)) { assetBundlePathIndexDic.Add(renderersLightmapData.m_lightmapIndex, texAssetBundlePath); assetBundlePathArr.Add(texAssetBundlePath); } } }