public void RecreateCopy()
        {
            ClearCopy();

            if (subgraph == null)
            {
                m_SubChildren  = null;
                m_UsedSubgraph = null;
                return;
            }

            var graph = m_Subgraph.GetResource().GetOrCreateGraph();
            HashSet <ScriptableObject> dependencies = new HashSet <ScriptableObject>();

            foreach (var child in graph.children.Where(t => t is VFXOperator || t is VFXParameter))
            {
                dependencies.Add(child);
                child.CollectDependencies(dependencies);
            }

            var copy = VFXMemorySerializer.DuplicateObjects(dependencies.ToArray());

            m_UsedSubgraph = graph;
            m_SubChildren  = copy.OfType <VFXModel>().Where(t => t is VFXOperator || t is VFXParameter).ToArray();

            foreach (var child in copy)
            {
                child.hideFlags = HideFlags.HideAndDontSave;
            }
        }
Beispiel #2
0
        protected internal override void Invalidate(VFXModel model, InvalidationCause cause)
        {
            if (cause == InvalidationCause.kSettingChanged)
            {
                var graph = GetGraph();

                if (graph != null && m_Subgraph != null && m_Subgraph.GetResource() != null)
                {
                    var otherGraph = m_Subgraph.GetResource().GetOrCreateGraph();
                    if (otherGraph == graph || otherGraph.subgraphDependencies.Contains(graph.GetResource().visualEffectObject))
                    {
                        m_Subgraph = null;              // prevent cyclic dependencies.
                    }
                    if (graph.GetResource().isSubgraph) // BuildSubgraphDependenciesis called for vfx by recompilation, but in subgraph we must call it explicitely
                    {
                        graph.BuildSubgraphDependencies();
                    }
                }
            }

            base.Invalidate(model, cause);
        }