public override bool RecursivePreviewUpdate(Dictionary <string, bool> duplicatesDict = null)
        {
            if (duplicatesDict == null)
            {
                duplicatesDict = ContainerGraph.ParentWindow.VisitedChanged;
            }

            for (int i = 0; i < InputPorts.Count; i++)
            {
                ParentNode outNode = null;
                if (Fnode != null)
                {
                    var input = Fnode.GetInput(this);
                    if (input.ExternalReferences.Count > 0)
                    {
                        outNode = Fnode.ContainerGraph.GetNode(input.ExternalReferences[0].NodeId);
                    }
                    else if (InputPorts[i].ExternalReferences.Count > 0)
                    {
                        outNode = ContainerGraph.GetNode(InputPorts[i].ExternalReferences[0].NodeId);
                    }
                }
                else
                {
                    if (InputPorts[i].ExternalReferences.Count > 0)
                    {
                        outNode = ContainerGraph.GetNode(InputPorts[i].ExternalReferences[0].NodeId);
                    }
                }
                if (outNode != null)
                {
                    if (!duplicatesDict.ContainsKey(outNode.OutputId))
                    {
                        bool result = outNode.RecursivePreviewUpdate();
                        if (result)
                        {
                            PreviewIsDirty = true;
                        }
                    }
                    else if (duplicatesDict[outNode.OutputId])
                    {
                        PreviewIsDirty = true;
                    }
                }
            }

            bool needsUpdate = PreviewIsDirty;

            RenderNodePreview();
            if (!duplicatesDict.ContainsKey(OutputId))
            {
                duplicatesDict.Add(OutputId, needsUpdate);
            }
            return(needsUpdate);
        }
        public override void SetPreviewInputs()
        {
            if (Fnode == null)
            {
                m_ignoreConnection = false;
                CheckSpherePreview();
            }
            else
            {
                var input = Fnode.GetInput(this);
                if (input != null && (!InputPorts[0].IsConnected || input.IsConnected))
                {
                    m_ignoreConnection = true;
                    InputPorts[0].PreparePortCacheID();
                    Fnode.SetPreviewInput(input);
                    if (input.ExternalReferences.Count > 0)
                    {
                        SpherePreview = Fnode.ContainerGraph.GetNode(input.ExternalReferences[0].NodeId).SpherePreview;
                    }
                    else
                    {
                        SpherePreview = false;
                    }
                    PreviewMaterial.SetTexture(InputPorts[0].CachedPropertyId, input.InputPreviewTexture(Fnode.ContainerGraph));
                }
                else
                {
                    m_ignoreConnection = false;
                    CheckSpherePreview();
                }
            }

            if (!m_ignoreConnection)
            {
                base.SetPreviewInputs();
            }

            for (int i = 0; i < OutputPorts[0].ExternalReferences.Count; i++)
            {
                ContainerGraph.GetNode(OutputPorts[0].ExternalReferences[i].NodeId).OnNodeChange();
            }

            if (m_typeId == -1)
            {
                m_typeId = Shader.PropertyToID("_Type");
            }

            if (m_inputPorts[0].DataType == WirePortDataType.FLOAT || m_inputPorts[0].DataType == WirePortDataType.INT)
            {
                PreviewMaterial.SetInt(m_typeId, 1);
            }
            else if (m_inputPorts[0].DataType == WirePortDataType.FLOAT2)
            {
                PreviewMaterial.SetInt(m_typeId, 2);
            }
            else if (m_inputPorts[0].DataType == WirePortDataType.FLOAT3)
            {
                PreviewMaterial.SetInt(m_typeId, 3);
            }
            else
            {
                PreviewMaterial.SetInt(m_typeId, 0);
            }
        }