private void BakeCustomReflectionProbe(ReflectionProbe probe, bool usePreviousAssetPath)
{
string assetPath = "";
if (usePreviousAssetPath)
{
assetPath = AssetDatabase.GetAssetPath(probe.customBakedTexture);
}
string extension = !probe.hdr ? "png" : "exr";
if (string.IsNullOrEmpty(assetPath) || (Path.GetExtension(assetPath) != ("." + extension)))
{
ReflectionProbe probe2;
string pathWithoutExtension = FileUtil.GetPathWithoutExtension(SceneManager.GetActiveScene().path);
if (string.IsNullOrEmpty(pathWithoutExtension))
{
pathWithoutExtension = "Assets";
}
else if (!Directory.Exists(pathWithoutExtension))
{
Directory.CreateDirectory(pathWithoutExtension);
}
string fileNameWithoutExtension = probe.name + (!probe.hdr ? "-reflection" : "-reflectionHDR") + "." + extension;
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(AssetDatabase.GenerateUniqueAssetPath(Path.Combine(pathWithoutExtension, fileNameWithoutExtension)));
assetPath = EditorUtility.SaveFilePanelInProject("Save reflection probe's cubemap.", fileNameWithoutExtension, extension, "", pathWithoutExtension);
if (string.IsNullOrEmpty(assetPath) || (this.IsCollidingWithOtherProbes(assetPath, probe, out probe2) && !EditorUtility.DisplayDialog("Cubemap is used by other reflection probe", string.Format("'{0}' path is used by the game object '{1}', do you really want to overwrite it?", assetPath, probe2.name), "Yes", "No")))
{
return;
}
}
EditorUtility.DisplayProgressBar("Reflection Probes", "Baking " + assetPath, 0.5f);
if (!Lightmapping.BakeReflectionProbe(probe, assetPath))
{
Debug.LogError("Failed to bake reflection probe to " + assetPath);
}
EditorUtility.ClearProgressBar();
}