浏览代码

Merge pull request #178 from Unity-Technologies/fix-preview-after-playmode

[FIX] fixes #166 Changed the Quad to use the build in resource from Unity
/main
GitHub 7 年前
当前提交
e9689ade
共有 2 个文件被更改,包括 2 次插入33 次删除
  1. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs
  2. 33
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/PreviewSceneResources.cs

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs


// Render 2D previews
m_SceneResources.camera.transform.position = -Vector3.forward * 2;
m_SceneResources.camera.transform.rotation = Quaternion.identity;
m_SceneResources.camera.orthographicSize = 1;
m_SceneResources.camera.orthographicSize = 0.5f;
m_SceneResources.camera.orthographic = true;
foreach (var renderData in m_RenderList2D)

33
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/PreviewSceneResources.cs


public class PreviewSceneResources : IDisposable
{
readonly Scene m_Scene;
static Mesh s_Quad;
Camera m_Camera;
public Light light0 { get; private set; }
public Light light1 { get; private set; }

Mesh quadMesh = Resources.GetBuiltinResource(typeof(Mesh), "Quad.fbx") as Mesh;
s_Meshes[4] = quadMesh;
}
if (s_Quad == null)
{
var vertices = new[]
{
new Vector3(-1f, -1f, 0f),
new Vector3(1f, 1f, 0f),
new Vector3(1f, -1f, 0f),
new Vector3(-1f, 1f, 0f)
};
var uvs = new[]
{
new Vector2(0f, 0f),
new Vector2(1f, 1f),
new Vector2(1f, 0f),
new Vector2(0f, 1f)
};
var indices = new[] { 0, 1, 2, 1, 0, 3 };
s_Quad = new Mesh
{
vertices = vertices,
uv = uvs,
triangles = indices
};
s_Quad.RecalculateNormals();
s_Quad.RecalculateBounds();
}
}
public Mesh sphere

public Mesh quad
{
get { return s_Quad; }
get { return s_Meshes[4]; }
}
public Material checkerboardMaterial

正在加载...
取消
保存