protected override void OnInvalidate(VFXModel model, VFXModel.InvalidationCause cause) { m_saved = false; if (cause == VFXModel.InvalidationCause.kStructureChanged || cause == VFXModel.InvalidationCause.kSettingChanged || cause == VFXModel.InvalidationCause.kConnectionChanged) { m_SystemNames.Sync(this); } base.OnInvalidate(model, cause); if (model is VFXParameter || //Something changed directly on VFXParameter (e.g. exposed state boolean) model is VFXSlot && (model as VFXSlot).owner is VFXParameter || //Something changed on a slot owned by a VFXParameter (e.g. the default value) cause == VFXModel.InvalidationCause.kStructureChanged //A VFXParameter could have been removed ) { BuildParameterInfo(); } if (cause == VFXModel.InvalidationCause.kStructureChanged) { UpdateSubAssets(); if (model == this) { VFXSubgraphContext.CallOnGraphChanged(this); } m_DependentDirty = true; } if (cause == VFXModel.InvalidationCause.kSettingChanged && model is VFXParameter) { VFXSubgraphContext.CallOnGraphChanged(this); m_DependentDirty = true; } if (cause != VFXModel.InvalidationCause.kExpressionInvalidated && cause != VFXModel.InvalidationCause.kExpressionGraphChanged && cause != VFXModel.InvalidationCause.kUIChangedTransient && (model.hideFlags & HideFlags.DontSave) == 0) { EditorUtility.SetDirty(this); } if (cause == VFXModel.InvalidationCause.kExpressionGraphChanged) { m_ExpressionGraphDirty = true; m_DependentDirty = true; } if (cause == VFXModel.InvalidationCause.kParamChanged) { m_ExpressionValuesDirty = true; m_DependentDirty = true; } }
void RecursePutSubgraphParent(Dictionary <VFXSubgraphContext, VFXSubgraphContext> parents, List <VFXSubgraphContext> subgraphs, VFXSubgraphContext subgraph) { foreach (var subSubgraph in subgraph.subChildren.OfType <VFXSubgraphContext>().Where(t => t.subgraph != null)) { subgraphs.Add(subSubgraph); parents[subSubgraph] = subgraph; RecursePutSubgraphParent(parents, subgraphs, subSubgraph); } }
protected override void OnInvalidate(VFXModel model, VFXModel.InvalidationCause cause) { m_saved = false; if (cause == VFXModel.InvalidationCause.kStructureChanged || cause == VFXModel.InvalidationCause.kSettingChanged) { m_SystemNames.Sync(this); } base.OnInvalidate(model, cause); if (model is VFXParameter || model is VFXSlot && (model as VFXSlot).owner is VFXParameter) { BuildParameterInfo(); } if (cause == VFXModel.InvalidationCause.kStructureChanged) { UpdateSubAssets(); if (model == this) { VFXSubgraphContext.CallOnGraphChanged(this); } m_DependentDirty = true; } if (cause == VFXModel.InvalidationCause.kSettingChanged && model is VFXParameter) { VFXSubgraphContext.CallOnGraphChanged(this); m_DependentDirty = true; } if (cause != VFXModel.InvalidationCause.kExpressionInvalidated && cause != VFXModel.InvalidationCause.kExpressionGraphChanged && cause != VFXModel.InvalidationCause.kUIChangedTransient && (model.hideFlags & HideFlags.DontSave) == 0) { EditorUtility.SetDirty(this); } if (cause == VFXModel.InvalidationCause.kExpressionGraphChanged || cause == VFXModel.InvalidationCause.kConnectionChanged) { m_ExpressionGraphDirty = true; m_DependentDirty = true; } if (cause == VFXModel.InvalidationCause.kParamChanged) { m_ExpressionValuesDirty = true; m_DependentDirty = true; } }
static List <VFXContextLink>[] ComputeContextEffectiveLinks(VFXContext context, ref SubgraphInfos subgraphInfos) { List <VFXContextLink>[] result = new List <VFXContextLink> [context.inputFlowSlot.Length]; Dictionary <string, int> eventNameIndice = new Dictionary <string, int>(); for (int i = 0; i < context.inputFlowSlot.Length; ++i) { result[i] = new List <VFXContextLink>(); VFXSubgraphContext parentSubgraph = null; subgraphInfos.spawnerSubgraph.TryGetValue(context, out parentSubgraph); List <VFXContext> subgraphAncestors = new List <VFXContext>(); subgraphAncestors.Add(context); while (parentSubgraph != null) { subgraphAncestors.Add(parentSubgraph); if (!subgraphInfos.subgraphParents.TryGetValue(parentSubgraph, out parentSubgraph)) { parentSubgraph = null; } } List <List <int> > defaultEventPaths = new List <List <int> >(); defaultEventPaths.Add(new List <int>(new int[] { i })); List <List <int> > newEventPaths = new List <List <int> >(); var usedContexts = new List <VFXContext>(); var namedEvents = new Dictionary <string, VFXContext>(); for (int j = 0; j < subgraphAncestors.Count; ++j) { var sg = subgraphAncestors[j]; var nextSg = j < subgraphAncestors.Count - 1 ? subgraphAncestors[j + 1] as VFXSubgraphContext : null; foreach (var path in defaultEventPaths) { int currentFlowIndex = path.Last(); var eventSlot = sg.inputFlowSlot[currentFlowIndex]; // -1 in path is Trigger therefore 2 in subgraph input var eventSlotSpawners = eventSlot.link.Where(t => !(t.context is VFXBasicEvent)); if (eventSlotSpawners.Any()) { foreach (var evt in eventSlotSpawners) { result[i].Add(evt); } } var eventSlotEvents = eventSlot.link.Where(t => t.context is VFXBasicEvent); if (eventSlotEvents.Any()) { foreach (var evt in eventSlotEvents) { string eventName = (evt.context as VFXBasicEvent).eventName; switch (eventName) { case VisualEffectAsset.PlayEventName: newEventPaths.Add(path.Concat(new int[] { 0 }).ToList()); break; case VisualEffectAsset.StopEventName: newEventPaths.Add(path.Concat(new int[] { 1 }).ToList()); break; default: { if (nextSg != null) { int eventIndex = nextSg.GetInputFlowIndex(eventName); if (eventIndex != -1) { namedEvents[eventName] = evt.context; newEventPaths.Add(path.Concat(new int[] { eventIndex }).ToList()); } } else { result[i].Add(evt); } } break; } } } else if (!eventSlot.link.Any()) { if (!(sg is VFXSubgraphContext)) { newEventPaths.Add(path.Concat(new int[] { currentFlowIndex }).ToList()); } else { var sgsg = sg as VFXSubgraphContext; var eventName = sgsg.GetInputFlowName(currentFlowIndex); var eventCtx = sgsg.GetEventContext(eventName); if (eventCtx != null) { result[i].Add(new VFXContextLink() { slotIndex = 0, context = eventCtx }); } } } } defaultEventPaths.Clear(); defaultEventPaths.AddRange(newEventPaths); newEventPaths.Clear(); } } return(result); }