|
|
|
|
|
|
private static readonly GUIContent[] s_LightIcons = {null, null}; |
|
|
|
private static readonly GUIContent[] s_TimeIcons = {null, null}; |
|
|
|
|
|
|
|
public MaterialGraphPreviewGenerator() |
|
|
|
private PreviewRenderUtility utility |
|
|
|
if (m_PreviewUtility == null) |
|
|
|
get |
|
|
|
m_PreviewUtility = new PreviewRenderUtility(); |
|
|
|
EditorUtility.SetCameraAnimateMaterials(m_PreviewUtility.m_Camera, true); |
|
|
|
if (m_PreviewUtility == null) |
|
|
|
m_PreviewUtility = new PreviewRenderUtility(); |
|
|
|
|
|
|
|
return m_PreviewUtility; |
|
|
|
} |
|
|
|
public void Reset() |
|
|
|
{ |
|
|
|
if (m_PreviewUtility != null) |
|
|
|
m_PreviewUtility.Cleanup(); |
|
|
|
|
|
|
|
m_PreviewUtility = null; |
|
|
|
} |
|
|
|
|
|
|
|
public MaterialGraphPreviewGenerator() |
|
|
|
{ |
|
|
|
EditorUtility.SetCameraAnimateMaterials(utility.m_Camera, true); |
|
|
|
|
|
|
|
if (s_Meshes[0] == null) |
|
|
|
{ |
|
|
|
var handleGo = (GameObject)EditorGUIUtility.LoadRequired("Previews/PreviewMaterials.fbx"); |
|
|
|
|
|
|
if (mat == null || mat.shader == null) |
|
|
|
return Texture2D.blackTexture; |
|
|
|
|
|
|
|
m_PreviewUtility.BeginPreview(size, GUIStyle.none); |
|
|
|
utility.BeginPreview(size, GUIStyle.none); |
|
|
|
m_PreviewUtility.m_Camera.transform.position = -Vector3.forward * 5; |
|
|
|
m_PreviewUtility.m_Camera.transform.rotation = Quaternion.identity; |
|
|
|
utility.m_Camera.transform.position = -Vector3.forward * 5; |
|
|
|
utility.m_Camera.transform.rotation = Quaternion.identity; |
|
|
|
m_PreviewUtility.m_Camera.projectionMatrix = Matrix4x4.identity; |
|
|
|
utility.m_Camera.projectionMatrix = Matrix4x4.identity; |
|
|
|
EditorUtility.SetCameraAnimateMaterialsTime(m_PreviewUtility.m_Camera, time); |
|
|
|
m_PreviewUtility.m_Light[0].intensity = 1.0f; |
|
|
|
m_PreviewUtility.m_Light[0].transform.rotation = Quaternion.Euler(50f, 50f, 0); |
|
|
|
m_PreviewUtility.m_Light[1].intensity = 1.0f; |
|
|
|
InternalEditorUtility.SetCustomLighting(m_PreviewUtility.m_Light, Color.black); |
|
|
|
EditorUtility.SetCameraAnimateMaterialsTime(utility.m_Camera, time); |
|
|
|
utility.m_Light[0].intensity = 1.0f; |
|
|
|
utility.m_Light[0].transform.rotation = Quaternion.Euler(50f, 50f, 0); |
|
|
|
utility.m_Light[1].intensity = 1.0f; |
|
|
|
InternalEditorUtility.SetCustomLighting(utility.m_Light, Color.black); |
|
|
|
m_PreviewUtility.m_Camera.clearFlags = CameraClearFlags.SolidColor; |
|
|
|
utility.m_Camera.clearFlags = CameraClearFlags.Depth; |
|
|
|
m_PreviewUtility.DrawMesh( |
|
|
|
utility.DrawMesh( |
|
|
|
m_PreviewUtility.m_Camera.Render(); |
|
|
|
utility.m_Camera.Render(); |
|
|
|
return m_PreviewUtility.EndPreview(); |
|
|
|
return utility.EndPreview(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |