Exemple #1
0
 void ReleaseUnmanagedResources()
 {
     if (m_ColorShader != null)
     {
         Object.DestroyImmediate(m_ColorShader, true);
         m_ColorShader = null;
     }
     if (m_ErrorTexture != null)
     {
         Object.DestroyImmediate(m_ErrorTexture);
         m_ErrorTexture = null;
     }
     if (m_PreviewMaterial != null)
     {
         Object.DestroyImmediate(m_PreviewMaterial, true);
         m_PreviewMaterial = null;
     }
     if (m_SceneResources != null)
     {
         m_SceneResources.Dispose();
         m_SceneResources = null;
     }
     if (m_MasterRenderData != null)
     {
         DestroyRenderData(m_MasterRenderData);
     }
     foreach (var renderData in m_RenderDatas.ToList().Where(x => x != null))
     {
         DestroyRenderData(renderData);
     }
     m_RenderDatas.Clear();
 }
Exemple #2
0
        public PreviewManager(AbstractMaterialGraph graph)
        {
            m_Graph           = graph;
            m_PreviewMaterial = new Material(Shader.Find("Unlit/Color"))
            {
                hideFlags = HideFlags.HideInHierarchy
            };
            m_PreviewMaterial.hideFlags = HideFlags.HideAndDontSave;
            m_PreviewPropertyBlock      = new MaterialPropertyBlock();
            m_ErrorTexture = new Texture2D(2, 2);
            m_ErrorTexture.SetPixel(0, 0, Color.magenta);
            m_ErrorTexture.SetPixel(0, 1, Color.black);
            m_ErrorTexture.SetPixel(1, 0, Color.black);
            m_ErrorTexture.SetPixel(1, 1, Color.magenta);
            m_ErrorTexture.filterMode = FilterMode.Point;
            m_ErrorTexture.Apply();
            m_SceneResources        = new PreviewSceneResources();
            m_ColorShader           = ShaderUtil.CreateShaderAsset(k_EmptyShader);
            m_ColorShader.hideFlags = HideFlags.HideAndDontSave;
            m_MasterRenderData      = new PreviewRenderData
            {
                renderTexture = new RenderTexture(400, 400, 16, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default)
                {
                    hideFlags = HideFlags.HideAndDontSave
                }
            };
            m_MasterRenderData.renderTexture.Create();

            foreach (var node in m_Graph.GetNodes <INode>())
            {
                AddPreview(node);
            }
        }
Exemple #3
0
        public PreviewManager(GraphData graph, MessageManager messenger)
        {
            m_Graph          = graph;
            m_Messenger      = messenger;
            m_ErrorTexture   = GenerateFourSquare(Color.magenta, Color.black);
            m_SceneResources = new PreviewSceneResources();

            foreach (var node in m_Graph.GetNodes <AbstractMaterialNode>())
            {
                AddPreview(node);
            }
        }
Exemple #4
0
 void ReleaseUnmanagedResources()
 {
     if (m_ErrorTexture != null)
     {
         Object.DestroyImmediate(m_ErrorTexture);
         m_ErrorTexture = null;
     }
     if (m_SceneResources != null)
     {
         m_SceneResources.Dispose();
         m_SceneResources = null;
     }
     foreach (var renderData in m_RenderDatas.Where(x => x != null))
     {
         DestroyRenderData(renderData);
     }
     m_RenderDatas.Clear();
 }
Exemple #5
0
 void ReleaseUnmanagedResources()
 {
     if (m_ErrorTexture != null)
     {
         Object.DestroyImmediate(m_ErrorTexture);
         m_ErrorTexture = null;
     }
     if (m_SceneResources != null)
     {
         m_SceneResources.Dispose();
         m_SceneResources = null;
     }
     foreach (var renderData in m_RenderDatas.Values)
     {
         DestroyRenderData(renderData);
     }
     m_RenderDatas.Clear();
     m_SharedPreviewPropertyBlock.Clear();
 }