The problem is, that I cant store objects when selecting them through the custom window.
Heres the code:
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class ShaderSetupEditor : EditorWindow
{
public Cubemap defaultCube = null;
public float exposure;
[MenuItem("X window/Setup")]
public static void ShowWindow()
{
EditorWindow.GetWindow(typeof(ShaderSetupEditor));
}
void UpdateShaders()
{
if(defaultCube) {
Shader.SetGlobalTexture("_Cube", defaultCube);
}
}
void OnGUI()
{
EditorGUILayout.LabelField("Chose a default cubemap for the shaders.");
EditorGUI.BeginChangeCheck();
{
string commandName = Event.current.commandName;
if (commandName == "ObjectSelectorUpdated") {
defaultCube = EditorGUIUtility.GetObjectPickerObject () as Cubemap;
Repaint ();
}
EditorGUILayout.ObjectField (defaultCube, typeof(Cubemap), true);
}
UpdateShaders();
}
}
Any sugestions?