using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using DG.Tweening.Plugins.Core.PathCore;
using UnityEngine.WSA;
using UnityEngine.SceneManagement;
using UnityEditor.VersionControl;
public class ReflectionProbeBake : EditorWindow
{
public string folder = string.Empty;
[MenuItem("Tools/ ReflectionProbe 烘焙")]
static void Init()
{
ReflectionProbeBake window = (ReflectionProbeBake)GetWindow(typeof(ReflectionProbeBake));
window.Show();
}
void Start()
{
}
private void OnGUI()
{
GUILayout.Space(10);
EditorGUILayout.BeginHorizontal();
folder = EditorGUILayout.TextField("RelectionProbe存放位置", folder);
if (GUILayout.Button("Set", GUILayout.Width(40f)))
{
folder = EditorUtility.OpenFolderPanel("select save path", "", "").Replace(UnityEngine.Application.dataPath, "Assets");
}
EditorGUILayout.EndHorizontal();
GUILayout.Space(10);
if (GUILayout.Button("烘焙"))
{
BakeReflectionPrefab(folder);
}
}
void BakeReflectionPrefab(string path)
{
if (string.IsNullOrEmpty(path))
{
Debug.LogError("存放位置不可爲空!");
return;
}
foreach (Object obj in Selection.objects)
{
if (((GameObject)obj).GetComponent<ReflectionProbe>())
{
ReflectionProbe reflectionProbe = ((GameObject)obj).GetComponent<ReflectionProbe>();
Lightmapping.BakeReflectionProbe(reflectionProbe, path + "/"+obj.name + ".exr");
}
}
Repaint();
}
}