public ConnectionPointData GetConnectionPoint(FilterEntry f) { ConnectionPointData p = m_outputPoints.Find(v => v.Id == f.ConnectionPointId); UnityEngine.Assertions.Assert.IsNotNull(p); return(p); }
public void RemoveFilterCondition(FilterEntry f) { ValidateAccess( NodeKind.FILTER_GUI ); m_filter.Remove(f); m_outputPoints.Remove(f.ConnectionPoint); }
public void AddFilterCondition(string keyword, string keytype) { ValidateAccess( NodeKind.FILTER_GUI ); var point = new ConnectionPointData(keyword, this, false); m_outputPoints.Add(point); var newEntry = new FilterEntry(keyword, keytype, point); m_filter.Add(newEntry); }
public void UpdateFilterEntry(FilterEntry f) { ConnectionPointData p = m_outputPoints.Find(v => v.Id == f.ConnectionPointId); UnityEngine.Assertions.Assert.IsNotNull(p); if (f.FilterKeytype == SaveDataConstants.DEFAULT_FILTER_KEYTYPE) { p.Label = f.FilterKeyword; } else { var pointIndex = f.FilterKeytype.LastIndexOf('.'); var keytypeName = (pointIndex > 0)? f.FilterKeytype.Substring(pointIndex + 1):f.FilterKeytype; p.Label = $"{f.FilterKeyword}[{keytypeName}]"; } }
public void FromJsonDictionary(Dictionary <string, object> jsonData) { m_name = jsonData[NODE_NAME] as string; m_id = jsonData[NODE_ID] as string; m_kind = SaveDataConstants.NodeKindFromString(jsonData[NODE_KIND] as string); m_scriptClassName = string.Empty; m_nodeNeedsRevisit = false; if (jsonData.ContainsKey(NODE_SCRIPT_CLASSNAME)) { m_scriptClassName = jsonData[NODE_SCRIPT_CLASSNAME] as string; } var pos = jsonData[NODE_POS] as Dictionary <string, object>; m_x = (float)Convert.ToDouble(pos[NODE_POS_X]); m_y = (float)Convert.ToDouble(pos[NODE_POS_Y]); var inputs = jsonData[NODE_INPUTPOINTS] as List <object>; var outputs = jsonData[NODE_OUTPUTPOINTS] as List <object>; m_inputPoints = new List <ConnectionPointData>(); m_outputPoints = new List <ConnectionPointData>(); foreach (var obj in inputs) { var pDic = obj as Dictionary <string, object>; m_inputPoints.Add(new ConnectionPointData(pDic, this, true)); } foreach (var obj in outputs) { var pDic = obj as Dictionary <string, object>; m_outputPoints.Add(new ConnectionPointData(pDic, this, false)); } switch (m_kind) { case NodeKind.IMPORTSETTING_GUI: // nothing to do break; case NodeKind.PREFABBUILDER_GUI: { if (jsonData.ContainsKey(NODE_PREFABBUILDER_REPLACEPREFABOPTIONS)) { m_prefabBuilderReplacePrefabOptions = Convert.ToInt32(jsonData[NODE_PREFABBUILDER_REPLACEPREFABOPTIONS]); } if (jsonData.ContainsKey(NODE_SCRIPT_INSTANCE_DATA)) { m_scriptInstanceData = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_SCRIPT_INSTANCE_DATA)); } } break; case NodeKind.MODIFIER_GUI: { if (jsonData.ContainsKey(NODE_SCRIPT_INSTANCE_DATA)) { m_scriptInstanceData = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_SCRIPT_INSTANCE_DATA)); } } break; case NodeKind.LOADER_GUI: { m_loaderLoadPath = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_LOADER_LOAD_PATH)); } break; case NodeKind.FILTER_GUI: { var filters = jsonData[NODE_FILTER] as List <object>; m_filter = new List <FilterEntry>(); for (int i = 0; i < filters.Count; ++i) { var f = filters[i] as Dictionary <string, object>; var keyword = f[NODE_FILTER_KEYWORD] as string; var keytype = f[NODE_FILTER_KEYTYPE] as string; var pointId = f[NODE_FILTER_POINTID] as string; var point = m_outputPoints.Find(p => p.Id == pointId); UnityEngine.Assertions.Assert.IsNotNull(point, "Output point not found for " + keyword); var newEntry = new FilterEntry(keyword, keytype, point); m_filter.Add(newEntry); UpdateFilterEntry(newEntry); } } break; case NodeKind.GROUPING_GUI: { m_groupingKeyword = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_GROUPING_KEYWORD)); } break; case NodeKind.BUNDLECONFIG_GUI: { m_bundleConfigBundleNameTemplate = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_BUNDLECONFIG_BUNDLENAME_TEMPLATE)); if (jsonData.ContainsKey(NODE_BUNDLECONFIG_USE_GROUPASVARIANTS)) { m_bundleConfigUseGroupAsVariants = Convert.ToBoolean(jsonData[NODE_BUNDLECONFIG_USE_GROUPASVARIANTS]); } m_variants = new List <Variant>(); if (jsonData.ContainsKey(NODE_BUNDLECONFIG_VARIANTS)) { var variants = jsonData[NODE_BUNDLECONFIG_VARIANTS] as List <object>; for (int i = 0; i < variants.Count; ++i) { var v = variants[i] as Dictionary <string, object>; var name = v[NODE_BUNDLECONFIG_VARIANTS_NAME] as string; var pointId = v[NODE_BUNDLECONFIG_VARIANTS_POINTID] as string; var point = m_inputPoints.Find(p => p.Id == pointId); UnityEngine.Assertions.Assert.IsNotNull(point, "Input point not found for " + name); var newVariant = new Variant(name, point); m_variants.Add(newVariant); UpdateVariant(newVariant); } } } break; case NodeKind.BUNDLEBUILDER_GUI: { m_bundleBuilderEnabledBundleOptions = new SerializableMultiTargetInt(_SafeGet(jsonData, NODE_BUNDLEBUILDER_ENABLEDBUNDLEOPTIONS)); } break; case NodeKind.EXPORTER_GUI: { m_exporterExportPath = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_EXPORTER_EXPORT_PATH)); m_exporterExportOption = new SerializableMultiTargetInt(_SafeGet(jsonData, NODE_EXPORTER_EXPORT_OPTION)); } break; default: throw new ArgumentOutOfRangeException(); } }
private void DoInspectorFilterGUI(NodeGUI node) { EditorGUILayout.HelpBox("Filter: Filter incoming assets by keywords and types. You can use regular expressions for keyword field.", MessageType.Info); UpdateNodeName(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { GUILayout.Label("Filter Settings:"); FilterEntry removing = null; for (int i = 0; i < node.Data.FilterConditions.Count; ++i) { var cond = node.Data.FilterConditions[i]; Action messageAction = null; using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("-", GUILayout.Width(30))) { removing = cond; } else { var newContainsKeyword = cond.FilterKeyword; GUIStyle s = new GUIStyle((GUIStyle)"TextFieldDropDownText"); using (new EditorGUILayout.HorizontalScope()) { newContainsKeyword = EditorGUILayout.TextField(cond.FilterKeyword, s, GUILayout.Width(120)); if (GUILayout.Button(cond.FilterKeytype, "Popup")) { var ind = i; // need this because of closure locality bug in unity C# NodeGUI.ShowFilterKeyTypeMenu( cond.FilterKeytype, (string selectedTypeStr) => { using (new RecordUndoScope("Modify Filter Type", node, true)){ node.Data.FilterConditions[ind].FilterKeytype = selectedTypeStr; } } ); } } if (newContainsKeyword != cond.FilterKeyword) { using (new RecordUndoScope("Modify Filter Keyword", node, true)){ cond.FilterKeyword = newContainsKeyword; // event must raise to propagate change to connection associated with point NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_LABELCHANGED, node, Vector2.zero, cond.ConnectionPoint)); } } } } if (messageAction != null) { using (new GUILayout.HorizontalScope()) { messageAction.Invoke(); } } } // add contains keyword interface. if (GUILayout.Button("+")) { using (new RecordUndoScope("Add Filter Condition", node)){ node.Data.AddFilterCondition( AssetBundleGraphSettings.DEFAULT_FILTER_KEYWORD, AssetBundleGraphSettings.DEFAULT_FILTER_KEYTYPE); } } if (removing != null) { using (new RecordUndoScope("Remove Filter Condition", node, true)){ // event must raise to remove connection associated with point NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_DELETED, node, Vector2.zero, removing.ConnectionPoint)); node.Data.RemoveFilterCondition(removing); } } } }