浏览代码

Make master preview refresh rendertexture on play mode change and check if rendertexture is null

/main
Jens Holm 7 年前
当前提交
dd879e77
共有 1 个文件被更改,包括 20 次插入10 次删除
  1. 30
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/MasterPreviewView.cs

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


middleContainer.AddManipulator(new Scrollable(OnScroll));
}
Add(middleContainer);
EditorApplication.playmodeStateChanged += RefreshRenderTextureSize;
}
void BuildContextualMenu(ContextualMenuPopulateEvent evt)

public void RefreshRenderTextureSize()
{
RenderTextureDescriptor descriptor = m_PreviewRenderHandle.renderTexture.descriptor;
if (Mathf.Approximately(descriptor.width, targetHeight) && Mathf.Approximately(descriptor.height, targetWidth))
RenderTextureDescriptor descriptor;
if (m_PreviewRenderHandle.renderTexture)
return;
}
descriptor = m_PreviewRenderHandle.renderTexture.descriptor;
descriptor.width = (int)m_PreviewTextureView.contentRect.width;
descriptor.height = (int)m_PreviewTextureView.contentRect.height;
descriptor.width = (int)m_PreviewTextureView.contentRect.width;
descriptor.height = (int)m_PreviewTextureView.contentRect.height;
if (Mathf.Approximately(descriptor.width, descriptor.height) && Mathf.Approximately(descriptor.height, descriptor.height))
{
return;
}
m_PreviewRenderHandle.renderTexture.Release();
Object.DestroyImmediate(m_PreviewRenderHandle.renderTexture);
m_PreviewRenderHandle.renderTexture = new RenderTexture(descriptor);
m_PreviewRenderHandle.renderTexture.Release();
Object.DestroyImmediate(m_PreviewRenderHandle.renderTexture);
}
else
{
descriptor = new RenderTextureDescriptor((int)targetWidth, (int)targetHeight, RenderTextureFormat.ARGB32, 16);
}
m_PreviewRenderHandle.renderTexture = new RenderTexture(descriptor) { hideFlags = HideFlags.HideAndDontSave };
DirtyMasterNode(ModificationScope.Node);
}

正在加载...
取消
保存