|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|