public override void Initialize(TreeGraphView graphView, NodeInfo info) { base.Initialize(graphView, info); contextSelector = new PopupField <SerializableMethod>( "Target Context", representativeMethods, 0, method => { if (representativeMethods.Count != 1) { GraphView.editorWindow.SetTargetContextType(contextSelector?.value); } return("Select"); }, method => { if (method == null) { return("Select"); } if (method.Method == null) { return("Missing"); } return(method.TargetContextType.ToString()); } ); typeLabel = new Label("None"); { // Because the choices property in PopupField is internal, which according to https://forum.unity.com/threads/maskfield-choices-internal.672670/ // is a bug. So we will use reflection to set it for now var property = contextSelector.GetType().GetProperty("choices", BindingFlags.Instance | BindingFlags.NonPublic); if (property == null) { throw new Exception("Reflection not working!!!"); } //Should be contextSelector.choices = representativeActions property.SetValue(contextSelector, representativeMethods); } VisualElement parameterContainer = TryGetParameterContainer(); var labelStyle = contextSelector.Q <Label>().style; labelStyle.paddingTop = 0f; labelStyle.paddingLeft = 4f; labelStyle.paddingRight = 7f; contextSelector[1].style.paddingBottom = 0f; //Set selector bottom padding to 0 typeLabel.style.minWidth = labelStyle.minWidth = 64f; typeLabel.style.paddingRight = typeLabel.style.paddingLeft = 8f; inputContainer.style.justifyContent = Justify.Center; inputContainer.Add(contextSelector); parameterContainer.Add(typeLabel); GraphView.editorWindow.OnTargetContextChangedMethods += RecalculateTargetContext; RecalculateTargetContext(); }