Files
tianrunCRM/Assets/CoolapeFrame/Editor/Inspectors/CLPrefabLightmapDataEditor.cs
2020-07-04 14:41:25 +08:00

64 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using Coolape;
public class CLPrefabLightmapDataEditor : Editor
{
// 把renderer上面的lightmap信息保存起来以便存储到prefab上面
public static void SaveLightmapInfo ()
{
GameObject go = Selection.activeGameObject;
if (go == null) {
EditorUtility.DisplayDialog("Alert", "Please select a gameObject!", "Okey");
return;
}
CLPrefabLightmapData data = go.GetComponent<CLPrefabLightmapData>();
if (data == null) {
data = go.AddComponent<CLPrefabLightmapData>();
}
data.SaveLightmap();
EditorUtility.SetDirty(go);
}
// 把保存的lightmap信息恢复到renderer上面
public static void LoadLightmapInfo()
{
GameObject go = Selection.activeGameObject;
if (go == null) {
EditorUtility.DisplayDialog("Alert", "Please select a gameObject!", "Okey");
return;
}
CLPrefabLightmapData data = go.GetComponent<CLPrefabLightmapData>();
if (data == null) {
EditorUtility.DisplayDialog("Alert", "Can't find [CLPrefabLightmapData] component!", "Okey");
return;
}
data.LoadLightmap();
EditorUtility.SetDirty(go);
}
public static void ClearLightmapInfo()
{
GameObject go = Selection.activeGameObject;
if (go == null) {
EditorUtility.DisplayDialog("Alert", "Please select a gameObject!", "Okey");
return;
}
CLPrefabLightmapData data = go.GetComponent<CLPrefabLightmapData>();
if (data == null) {
EditorUtility.DisplayDialog("Alert", "Can't find [CLPrefabLightmapData] component!", "Okey");
return;
}
data.m_RendererInfo.Clear();
data.m_Lightmaps = null;
EditorUtility.SetDirty(go);
}
}