public static bool SetupLightmap(Object lightmapAssetObj)
        {
            if (!(lightmapAssetObj is LightMapAsset))
            {
                return(false);
            }


            LightMapAsset lightmapAsset = (LightMapAsset)lightmapAssetObj;

            if (lightmapAsset.lightmapFar == null || lightmapAsset.lightmapNear == null || lightmapAsset.lightmapFar.Length != lightmapAsset.lightmapNear.Length)
            {
                return(false);
            }

            int count = lightmapAsset.lightmapFar.Length;

            LightmapData[] lightmapDatas = new LightmapData[count];
            for (int i = 0; i < count; ++i)
            {
                LightmapData Lightmap = new LightmapData();
                Lightmap.lightmapFar  = lightmapAsset.lightmapFar[i];
                Lightmap.lightmapNear = lightmapAsset.lightmapNear[i];
                lightmapDatas[i]      = Lightmap;
            }
            LightmapSettings.lightmaps = lightmapDatas;
            return(true);
        }
            private bool GetBuildLightmapParams(AssetBundleData assetBundleData, string filePath, List <Object> assetObjectList, List <string> assetObjectNameList, List <string> savePathList, string lightmapScene)
            {
                if (string.IsNullOrEmpty(lightmapScene))
                {
                    return(true);
                }

                string currentScene = EditorApplication.currentScene;

                if (!AssetDatabase.OpenAsset(AssetDatabase.LoadMainAssetAtPath(URL.assets + "/" + lightmapScene)))
                {
                    Debug.LogError("Cannot open the scene:" + filePath);
                    return(false);
                }

                if (LightmapSettings.lightmaps == null || LightmapSettings.lightmaps.Length == 0)
                {
                    Debug.LogWarning("There is no lightmap data in the scene:" + filePath);
                    return(true);
                }

                LightMapAsset lightmapAsset = ScriptableObject.CreateInstance <LightMapAsset>();
                int           count         = LightmapSettings.lightmaps.Length;

                lightmapAsset.lightmapFar  = new Texture2D[count];
                lightmapAsset.lightmapNear = new Texture2D[count];
                for (int i = 0; i < count; ++i)
                {
                    lightmapAsset.lightmapFar[i]  = LightmapSettings.lightmaps[i].lightmapFar;
                    lightmapAsset.lightmapNear[i] = LightmapSettings.lightmaps[i].lightmapNear;
                }
                string assetPath = URL.assets + "/" + filePath + ".lightmap.asset";

                assetBundleData.garbageAssetList.Add(assetPath);
                AssetDatabase.CreateAsset(lightmapAsset, assetPath);
                assetObjectList.Add(AssetDatabase.LoadAssetAtPath(assetPath, typeof(LightMapAsset)));
                assetObjectNameList.Add(filePath + ".lightmap");
                savePathList.Add(filePath + ".lightmap.unity3d");

                if (string.IsNullOrEmpty(currentScene))
                {
                    EditorApplication.NewScene();
                }
                else
                {
                    AssetDatabase.OpenAsset(AssetDatabase.LoadMainAssetAtPath(currentScene));
                }

                return(true);
            }