//... static void ParameterDropDown(GUIContent content, BBParameter bbParam) { if (bbParam.varRef == null && !string.IsNullOrEmpty(bbParam.name)) { bbParam.name = EditorGUILayout.DelayedTextField(content, bbParam.name); GUI.backgroundColor = Color.white.WithAlpha(0.5f); if (bbParam.bb != null && GUILayout.Button(EditorUtils.GetTempContent(Icons.plusIcon, "Promote To Variable"), Styles.centerLabel, GUILayout.Width(18), GUILayout.Height(16))) { var menu = new GenericMenu(); foreach (var bb in bbParam.bb.GetAllParents(true).Reverse()) { menu.AddItem(new GUIContent($"Promote Variable in '{bb.identifier}' Blackboard"), false, () => { UndoUtility.RecordObject(bb.unityContextObject, "Promote Variable"); bbParam.PromoteToVariable(bb); UndoUtility.SetDirty(bb.unityContextObject); }); } menu.ShowAsContext(); } GUI.backgroundColor = Color.white; return; } GUI.color = new Color(0.9f, 0.9f, 1f, 1f); EditorGUILayout.PrefixLabel(content); var rect = EditorGUILayout.GetControlRect(false); rect.xMin += 2; // O.o var cachedContentTextForNew = string.IsNullOrEmpty(content.text) ? string.Format("new{0}", bbParam.varType.Name) : content.text; var displayName = bbParam.isNone ? "[NONE]" : bbParam.name; var pop = EditorGUI.DropdownButton(rect, EditorUtils.GetTempContent(displayName), FocusType.Passive); GUI.color = Color.white; if (pop) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("[NONE]"), false, () => { bbParam.name = string.Empty; }); foreach (var globalBB in GlobalBlackboard.GetAll()) { var globalVars = globalBB.GetVariables(bbParam.varType); if (globalVars.Count() == 0) { menu.AddDisabledItem(new GUIContent(globalBB.identifier + "/No Assignable Variables")); continue; } foreach (var variable in globalVars) { menu.AddItem(new GUIContent(globalBB.identifier + "/" + variable.name), bbParam.targetVariableID == variable.ID, () => { bbParam.SetTargetVariable(globalBB, variable); }); } } if (bbParam.bb != null) { foreach (var actualBB in bbParam.bb.GetAllParents(true).Reverse()) { var variables = actualBB.variables.Values.Where(v => v.CanConvertTo(bbParam.varType)); if (variables.Count() == 0) { menu.AddDisabledItem(new GUIContent(actualBB.identifier + "/No Assignable Variables")); continue; } foreach (var variable in variables) { menu.AddItem(new GUIContent(actualBB.identifier + "/" + variable.name), bbParam.targetVariableID == variable.ID, () => { bbParam.SetTargetVariable(actualBB, variable); }); } } } menu.AddSeparator(string.Empty); if (bbParam.bb != null) { foreach (var targetBB in bbParam.bb.GetAllParents(true).Reverse()) { menu.AddItem(new GUIContent("(Create New)/In '" + targetBB.identifier + "' Blackboard"), false, () => { UndoUtility.RecordObject(targetBB.unityContextObject, "New Variable"); if (targetBB.AddVariable(cachedContentTextForNew, bbParam.varType) != null) { bbParam.name = cachedContentTextForNew; } else { bbParam.name = null; } UndoUtility.SetDirty(targetBB.unityContextObject); }); } } menu.AddItem(new GUIContent("(DynamicVar)"), false, () => { bbParam.name = "_"; }); menu.DropDown(rect); } }