public VFXBlackboardCategory AddCategory(string initialName) { var newCategoryName = VFXParameterController.MakeNameUnique(initialName, new HashSet <string>(m_Categories.Keys)); var newCategory = new VFXBlackboardCategory { title = newCategoryName }; newCategory.SetSelectable(); this.m_Categories.Add(newCategoryName, newCategory); this.Add(newCategory); return(newCategory); }
void IControlledElement.OnControllerChanged(ref ControllerChangedEvent e) { if (e.controller != controller && !(e.controller is VFXParameterController)) //optim : reorder only is only the order has changed return; if (e.controller == controller && e.change == VFXViewController.Change.assetName) { title = controller.name; return; } if( controller.model.subgraph is VisualEffectSubgraphOperator && m_OutputCategory == null) { m_OutputCategory = new VFXBlackboardCategory() { title = "Output" }; m_OutputCategory.headerVisible = true; m_OutputCategory.expanded = PlayerPrefs.GetInt("VFX.blackboard.outputexpanded", 0) != 0; Add(m_OutputCategory); m_OutputCategory.AddToClassList("output"); } else if(!(controller.model.subgraph is VisualEffectSubgraphOperator) && m_OutputCategory != null ) { Remove(m_OutputCategory); m_OutputCategory = null; } var actualControllers = new HashSet<VFXParameterController>(controller.parameterControllers.Where(t => !t.isOutput && string.IsNullOrEmpty(t.model.category))); m_DefaultCategory.SyncParameters(actualControllers); var orderedCategories = controller.graph.UIInfos.categories; var newCategories = new List<VFXBlackboardCategory>(); if (orderedCategories != null) { foreach (var catModel in controller.graph.UIInfos.categories) { VFXBlackboardCategory cat = null; if (!m_Categories.TryGetValue(catModel.name, out cat)) { cat = new VFXBlackboardCategory() {title = catModel.name }; cat.SetSelectable(); m_Categories.Add(catModel.name, cat); } m_ExpandedStatus[catModel.name] = !catModel.collapsed; newCategories.Add(cat); } foreach (var category in m_Categories.Keys.Except(orderedCategories.Select(t => t.name)).ToArray()) { m_Categories[category].RemoveFromHierarchy(); m_Categories.Remove(category); m_ExpandedStatus.Remove(category); } } var prevCat = m_DefaultCategory; foreach (var cat in newCategories) { if (cat.parent == null) Insert(IndexOf(prevCat) + 1, cat); else cat.PlaceInFront(prevCat); prevCat = cat; } if(m_OutputCategory != null) m_OutputCategory.PlaceInFront(prevCat); foreach (var cat in newCategories) { actualControllers = new HashSet<VFXParameterController>(controller.parameterControllers.Where(t => t.model.category == cat.title && !t.isOutput)); cat.SyncParameters(actualControllers); cat.expanded = m_ExpandedStatus[cat.title]; } if (m_OutputCategory != null) { var outputControllers = new HashSet<VFXParameterController>(controller.parameterControllers.Where(t => t.isOutput)); m_OutputCategory.SyncParameters(outputControllers); } m_PathLabel.text = controller.graph.categoryPath; }
void IControlledElement.OnControllerChanged(ref ControllerChangedEvent e) { if (e.controller == controller || e.controller is VFXParameterController) //optim : reorder only is only the order has changed { if (e.controller == controller && e.change == VFXViewController.Change.assetName) { title = controller.name; return; } var orderedCategories = controller.graph.UIInfos.categories; var newCategories = new List <VFXBlackboardCategory>(); if (orderedCategories != null) { foreach (var catModel in controller.graph.UIInfos.categories) { VFXBlackboardCategory cat = null; if (!m_Categories.TryGetValue(catModel.name, out cat)) { cat = new VFXBlackboardCategory() { title = catModel.name }; cat.SetSelectable(); m_Categories.Add(catModel.name, cat); } m_ExpandedStatus[catModel.name] = !catModel.collapsed; newCategories.Add(cat); } foreach (var category in m_Categories.Keys.Except(orderedCategories.Select(t => t.name)).ToArray()) { m_Categories[category].RemoveFromHierarchy(); m_Categories.Remove(category); m_ExpandedStatus.Remove(category); } } var prevCat = m_DefaultCategory; foreach (var cat in newCategories) { if (cat.parent == null) { Insert(IndexOf(prevCat) + 1, cat); } else { cat.PlaceInFront(prevCat); } prevCat = cat; } var actualControllers = new HashSet <VFXParameterController>(controller.parameterControllers.Where(t => string.IsNullOrEmpty(t.model.category))); m_DefaultCategory.SyncParameters(actualControllers); foreach (var cat in newCategories) { actualControllers = new HashSet <VFXParameterController>(controller.parameterControllers.Where(t => t.model.category == cat.title)); cat.SyncParameters(actualControllers); cat.expanded = m_ExpandedStatus[cat.title]; } } }