浏览代码

Add zoom to master preview

/main
Jens Holm 7 年前
当前提交
625ddde1
共有 3 个文件被更改,包括 14 次插入2 次删除
  1. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs
  2. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/MasterPreviewView.cs
  3. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs


[NonSerialized]
public Quaternion rotation = Quaternion.identity;
[NonSerialized]
public float scale = 1f;
}
}

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/MasterPreviewView.cs


m_PreviewScrollPosition = new Vector2(0f, 0f);
middleContainer.Add(m_PreviewTextureView);
middleContainer.AddManipulator(new Scrollable(OnScroll));
void OnScroll(float scrollValue)
{
float rescaleAmount = -scrollValue * .03f;
m_Graph.previewData.scale = Mathf.Clamp(m_Graph.previewData.scale + rescaleAmount, 0.2f, 5f);
}
{
{
foreach (var primitiveTypeName in Enum.GetNames(typeof(PrimitiveType)))
{
if(m_DoNotShowPrimitives.Contains(primitiveTypeName))

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


{
var mesh = m_Graph.previewData.serializedMesh.mesh ? m_Graph.previewData.serializedMesh.mesh : m_SceneResources.sphere;
var previewTransform = Matrix4x4.Rotate(m_Graph.previewData.rotation);
previewTransform *= Matrix4x4.Scale(Vector3.one * (Vector3.one).magnitude / mesh.bounds.size.magnitude);
var scale = m_Graph.previewData.scale;
previewTransform *= Matrix4x4.Scale(scale * Vector3.one * (Vector3.one).magnitude / mesh.bounds.size.magnitude);
previewTransform *= Matrix4x4.Translate(-mesh.bounds.center);
RenderPreview(masterRenderData, mesh, previewTransform);
}

正在加载...
取消
保存