- 最后登录
- 2021-7-6
- 注册时间
- 2012-12-27
- 阅读权限
- 90
- 积分
- 76145
- 纳金币
- 53488
- 精华
- 316
|
using UnityEngine;
using UnityEditor;
using System.Collections;
public class GenerateCubeMapTool : EditorWindow {
private Cubemap cubemap;
private GameObject obj;
// // Use this for initialization
// void Start () {
// }
// Update is called once per frame
void Update () {
}
[MenuItem("Tools/GenerateCubeMapTool")]
static void Init () {
// GenerateCubeMapTool window = (GenerateCubeMapTool) EditorWindow.GetWindow(typeof(GenerateCubeMapTool));
EditorWindow.GetWindow (typeof(GenerateCubeMapTool));
}
void OnGUI () {
EditorGUILayout.Space ();
this.cubemap = (Cubemap) EditorGUILayout.ObjectField (this.cubemap, typeof(Cubemap), false);
EditorGUILayout.Space ();
if ( GUILayout.Button ("Select Camera Object in Scene")) {
if (Selection.activeGameObject) {
this.obj = Selection.activeGameObject;
}
}
if (this.obj != null) {
EditorGUILayout.HelpBox ("obj name : " + this.obj.name, MessageType.None);
}
EditorGUILayout.Space ();
if (this.obj != null) {
if (GUILayout.Button ("Render to Cubemap")) {
this.renderToCubeMap();
}
}
}
void renderToCubeMap() {
if (this.cubemap != null && this.obj.camera != null) {
this.obj.camera.RenderToCubemap(this.cubemap);
}
else if (this.obj.camera == null) {
Debug.Log("Please make sure the gameObject has the camera component");
}
else if (this.cubemap == null) {
Debug.Log("Please select the cubemap, and try again.");
}
}
}
|
|