|
|
|
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.Experimental.Rendering; |
|
|
|
using UnityEngine.Experimental.Rendering.HDPipeline; |
|
|
|
|
|
|
|
[CustomEditorForRenderPipeline(typeof(Cubemap), typeof(HDRenderPipelineAsset))] |
|
|
|
|
|
|
Rotating = 2 |
|
|
|
} |
|
|
|
|
|
|
|
private static Mesh s_SphereMesh; |
|
|
|
private Material m_ReflectiveMaterial; |
|
|
|
static Mesh s_SphereMesh; |
|
|
|
Material m_ReflectiveMaterial; |
|
|
|
private PreviewRenderUtility m_PreviewUtility; |
|
|
|
PreviewRenderUtility m_PreviewUtility; |
|
|
|
private float m_CameraPhi = 0.75f; |
|
|
|
private float m_CameraTheta = 0.5f; |
|
|
|
private float m_CameraDistance = 2.0f; |
|
|
|
float m_CameraPhi = 0.75f; |
|
|
|
float m_CameraTheta = 0.5f; |
|
|
|
float m_CameraDistance = 2.0f; |
|
|
|
private NavMode m_NavMode = NavMode.None; |
|
|
|
private Vector2 m_PreviousMousePosition = Vector2.zero; |
|
|
|
NavMode m_NavMode = NavMode.None; |
|
|
|
Vector2 m_PreviousMousePosition = Vector2.zero; |
|
|
|
static GUIContent s_MipMapLow, s_MipMaipHigh, s_CurveKeyframeSelected, s_CurveKeyframeSemiSelectedOverlay, s_RGBMIcon; |
|
|
|
static GUIContent s_MipMapLow, s_MipMapHigh, s_CurveKeyframeSelected, s_CurveKeyframeSemiSelectedOverlay, s_RGBMIcon; |
|
|
|
private void OnEnable() |
|
|
|
void OnEnable() |
|
|
|
Debug.Log("created new"); |
|
|
|
InitIcons(); |
|
|
|
//m_ReflectiveMaterial = Instantiate((Material)AssetDatabase.LoadAssetAtPath("Assets/ScriptableRenderPipeline/ScriptableRenderPipeline/HDRenderPipeline/Debug/PreviewCubemapMaterial.mat", typeof(Material)));
|
|
|
|
private void OnDisable() |
|
|
|
void OnDisable() |
|
|
|
{ |
|
|
|
} |
|
|
|
private static Mesh sphereMesh |
|
|
|
static Mesh sphereMesh |
|
|
|
{ |
|
|
|
get { return s_SphereMesh ?? (s_SphereMesh = Resources.GetBuiltinResource(typeof(Mesh), "New-Sphere.fbx") as Mesh); } |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void InitPreview() |
|
|
|
void InitPreview() |
|
|
|
{ |
|
|
|
m_PreviewUtility = new PreviewRenderUtility(false, true); |
|
|
|
m_PreviewUtility.cameraFieldOfView = 50.0f; |
|
|
|
|
|
|
//m_PreviewUtility.camera.clearFlags = CameraClearFlags.Skybox;
|
|
|
|
} |
|
|
|
|
|
|
|
private void InitIcons() |
|
|
|
static void InitIcons() |
|
|
|
s_MipMaipHigh = EditorGUIUtility.IconContent("PreTextureMipMapHigh"); |
|
|
|
s_MipMapHigh = EditorGUIUtility.IconContent("PreTextureMipMapHigh"); |
|
|
|
s_CurveKeyframeSelected = EditorGUIUtility.IconContent("d_curvekeyframeselected"); |
|
|
|
s_CurveKeyframeSemiSelectedOverlay = EditorGUIUtility.IconContent("d_curvekeyframesemiselectedoverlay"); |
|
|
|
s_RGBMIcon = EditorGUIUtility.IconContent("PreMatLight1"); // TODO: proper icon for RGBM preview mode
|
|
|
|
|
|
|
{ |
|
|
|
GUI.enabled = true; |
|
|
|
|
|
|
|
InitIcons(); |
|
|
|
|
|
|
|
GUI.enabled = true; |
|
|
|
GUILayout.Box(s_MipMapHigh, s_PreLabel, GUILayout.MaxWidth(20)); |
|
|
|
GUI.changed = false; |
|
|
|
m_MipLevelPreview = GUILayout.HorizontalSlider(m_MipLevelPreview, 0, ((Cubemap)target).mipmapCount, GUILayout.MaxWidth(80)); |
|
|
|
GUILayout.Box(s_MipMapLow, s_PreLabel, GUILayout.MaxWidth(20)); |
|
|
|
GUILayout.Space(5); |
|
|
|
GUI.enabled = true; |
|
|
|
bool result = false; |
|
|
|
var result = false; |
|
|
|
|
|
|
|
if (Event.current.type == EventType.MouseDown) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
if (m_NavMode != NavMode.None) |
|
|
|
{ |
|
|
|
Vector2 mouseDelta = Event.current.mousePosition - m_PreviousMousePosition; |
|
|
|
var mouseDelta = Event.current.mousePosition - m_PreviousMousePosition; |
|
|
|
switch (m_NavMode) |
|
|
|
{ |
|
|
|
case NavMode.Rotating: |
|
|
|
|
|
|
|
|
|
|
private void UpdateCamera() |
|
|
|
{ |
|
|
|
Vector3 pos = new Vector3(Mathf.Sin(m_CameraPhi) * Mathf.Cos(m_CameraTheta), Mathf.Cos(m_CameraPhi), Mathf.Sin(m_CameraPhi) * Mathf.Sin(m_CameraTheta)) * m_CameraDistance; |
|
|
|
var pos = new Vector3(Mathf.Sin(m_CameraPhi) * Mathf.Cos(m_CameraTheta), Mathf.Cos(m_CameraPhi), Mathf.Sin(m_CameraPhi) * Mathf.Sin(m_CameraTheta)) * m_CameraDistance; |
|
|
|
m_PreviewUtility.camera.transform.position = pos; |
|
|
|
m_PreviewUtility.camera.transform.LookAt(Vector3.zero); |
|
|
|
} |