浏览代码

Previews work properly again and switch between 2d and 3d properly.

/main
Tim Cooper 8 年前
当前提交
b3888385
共有 2 个文件被更改,包括 34 次插入17 次删除
  1. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/NodePreviewDrawData.cs
  2. 49
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphPreviewGenerator.cs

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/NodePreviewDrawData.cs


bool status = false;
if (m_modificationScope == ModificationScope.Graph)
{
previewGenerator.Reset();
// TODO: Handle shader regeneration error
status = UpdatePreviewShader();
}

49
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphPreviewGenerator.cs


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();
}
}
}
正在加载...
取消
保存