public static VisualElement CreateScenarioEndingList(SerializedProperty listProperty, string label, bool useHeader = false) { var list = new Foldout { text = label }; var endingList = ((ScenarioEnding[])Enum.GetValues(typeof(ScenarioEnding))).ToList(); listProperty.arraySize = endingList.Count; listProperty.serializedObject.ApplyModifiedProperties(); for (var i = 0; i < endingList.Count; i++) { VisualElement listElem; if (useHeader) { list.Add(new Label(endingList[i].ToDisplayName()) { style = { unityFontStyleAndWeight = new StyleEnum <FontStyle>(FontStyle.Bold) } }); listElem = new PropertyField(listProperty.GetArrayElementAtIndex(i)); } else { listElem = new PropertyField(listProperty.GetArrayElementAtIndex(i), endingList[i].ToDisplayName()); } list.Add(listElem); } return(list); }
protected override VisualElement Repaint(SerializedProperty property) { var container = new Foldout() { text = property.displayName }; var typeName = property.FindPropertyRelative("typeName"); var memberName = property.FindPropertyRelative("memberName"); var operatorName = property.FindPropertyRelative("operatorName"); container.Add(CreateTypePopup(typeName)); container.Add(CreatePropertyPopup(memberName, typeName.stringValue)); var propertyInfo = GetProperty(typeName.stringValue, memberName.stringValue); var operators = Operators; if (propertyInfo?.PropertyType.IsNumeric() == false) { operators = operators.Take(1).ToList(); operatorName.stringValue = operators.First(); property.serializedObject.ApplyModifiedProperties(); property.serializedObject.Update(); } container.Add(CreateOperatorPopup(operatorName, operators)); container.Add(CreateValueField(property, propertyInfo)); return(container); }
protected override void OnInitialized() { base.OnInitialized(); if (!typeof(GOAPAction).IsAssignableFrom(T_Model.GetType())) { return; } for (int i = 0; i < T_Model.Preconditions.Count; i++) { VisualElement v = CreateToggle(T_Model.Preconditions[i], (ele, state) => { T_Model.RemovePrecondition(state); ele.RemoveFromHierarchy(); }); conditionFoldout.Add(v); ConditionElements[T_Model.Preconditions[i]] = v; } for (int i = 0; i < T_Model.Effects.Count; i++) { VisualElement v = CreateToggle(T_Model.Effects[i], (ele, state) => { T_Model.RemoveEffect(state); ele.RemoveFromHierarchy(); }); effectFoldout.Add(v); EffectElements[T_Model.Effects[i]] = v; } }
public override VisualElement CreatePropertyGUI(SerializedProperty property) { var container = new VisualElement(); var foldout = new Foldout { text = property.displayName }; var objField = new ObjectField("Reference") { objectType = typeof(Entity), allowSceneObjects = false }; var mValue = property.FindPropertyRelative("mValue"); if (mValue == null) { return(container); } objField.BindProperty(mValue); foldout.Add(new VariablePopup <SharedEntity>(property)); foldout.Add(objField); container.Add(foldout); return(container); }
public VisualElement GetVisualElement() { VisualElement visualElement = new VisualElement(); m_NameElement = new Foldout(); m_NameElement.Add(visualElement); visualElement.Add(GetSwapVisualElement()); visualElement.Add(GetNameFieldVisualElement()); visualElement.Add(GeDescriptionFieldVisualElement()); VisualElement actionsElement = new Foldout { text = "Actions" }; actionsElement.Add(GetShapeActionsListVisualElement()); actionsElement.Add(new ValidatorField(m_Stage.NoConflictsBetweenShapeActionsValidator)); actionsElement.Add(GetCreateShapeActionVisualElement()); visualElement.Add(actionsElement); visualElement.Add(GetDeleteStageVisualElement()); m_NameElement.AddToClassList("container"); UpdateName(); return(m_NameElement); }
public override VisualElement CreateInspectorGUI() { var root = new VisualElement(); root.Add(new PropertyField(serializedObject.FindProperty("scenarioName"))); root.Add(new PropertyField(serializedObject.FindProperty("icon"))); root.Add(UITools.CreateScenarioEndingList(serializedObject.FindProperty("midwayBackgrounds"), "Scenario midway backgrounds")); root.Add(UITools.CreateScenarioEndingList(serializedObject.FindProperty("endBackgrounds"), "Scenario ending backgrounds")); root.Add(UITools.CreateScenarioEndingList(serializedObject.FindProperty("endingMessages"), "Ending messages", true)); var audioFoldout = new Foldout { text = "Music" }; audioFoldout.Add(new PropertyField(serializedObject.FindProperty("neutralMusic"))); audioFoldout.Add(new PropertyField(serializedObject.FindProperty("negativeMusic"))); audioFoldout.Add(new PropertyField(serializedObject.FindProperty("positiveMusic"))); root.Add(audioFoldout); root.Add(new PostList(serializedObject.FindProperty("posts"), serializedObject)); return(root); }
private VisualElement GetEditorSystemDataElement() { var foldout = new Foldout { text = "Editor systems", value = false, contentContainer = { style = { marginLeft = 5 } } }; if (GFEditorSystemUtility.GetSystemsData(target as Setup)) { LoadLocal(); } else { LoadBase(); } void LoadBase() { foldout.Clear(); foldout.Add(new Button(LoadLocal) { text = "Add local data" }); var local = GFEditorSystemUtility.GetSystemsData(target as Setup); if (local) { GFEditorSystemUtility.RemoveSystemsData(target as Setup); EditorFramework.IsNeedRefreshSystems = true; } } void LoadLocal() { foldout.Clear(); var local = GFEditorSystemUtility.GetSystemsData(target as Setup); if (!local) { local = GFEditorSystemUtility.AddSystemsData(target as Setup); EditorFramework.IsNeedRefreshSystems = true; } foldout.Add(new Button(LoadBase) { text = "Remove local data" }); var element = new InspectorElement(local); foldout.Add(element); } return(foldout); }
public override VisualElement Build() { var root = new Foldout { text = DisplayName }; var majorField = new IntegerField { bindingPath = nameof(Version.Major), label = ObjectNames.NicifyVariableName(nameof(Version.Major)) }; majorField.RegisterCallback <ChangeEvent <int>, IntegerField>(ClampEditingValue, majorField); majorField.RegisterValueChangedCallback(OnMajorChanged); root.Add(majorField); var minorField = new IntegerField { bindingPath = nameof(Version.Minor), label = ObjectNames.NicifyVariableName(nameof(Version.Minor)) }; minorField.RegisterCallback <ChangeEvent <int>, IntegerField>(ClampEditingValue, minorField); minorField.RegisterValueChangedCallback(OnMinorChanged); root.Add(minorField); var usage = GetAttribute <SystemVersionUsageAttribute>(); if (usage?.IncludeBuild ?? true) { var buildField = new IntegerField { bindingPath = nameof(Version.Build), label = ObjectNames.NicifyVariableName(nameof(Version.Build)) }; buildField.RegisterCallback <ChangeEvent <int>, IntegerField>(ClampEditingValue, buildField); buildField.RegisterValueChangedCallback(OnBuildChanged); root.Add(buildField); } if (usage?.IncludeRevision ?? true) { var revisionField = new IntegerField { bindingPath = nameof(Version.Revision), label = ObjectNames.NicifyVariableName(nameof(Version.Revision)) }; revisionField.RegisterCallback <ChangeEvent <int>, IntegerField>(ClampEditingValue, revisionField); revisionField.RegisterValueChangedCallback(OnRevisionChanged); root.Add(revisionField); } if (IsReadOnly) { root.contentContainer.SetEnabled(false); } return(root); }
private VisualElement GetSceneObjetsOrderElement() { var foldout = new Foldout { text = "Scene objects order", value = false, contentContainer = { style = { marginLeft = 5 } } }; if (GFContextSystemUtility.GetSystemOrder(target as GFContext)) { LoadLocal(); } else { LoadBase(); } void LoadBase() { foldout.Clear(); foldout.Add(new Button(LoadLocal) { text = "Add local data" }); var local = GFContextSystemUtility.GetSystemOrder(target as GFContext); if (local) { GFContextSystemUtility.RemoveSystemOrder(target as GFContext); } } void LoadLocal() { foldout.Clear(); var local = GFContextSystemUtility.GetSystemOrder(target as GFContext); if (!local) { local = GFContextSystemUtility.AddSystemOrder(target as GFContext); } foldout.Add(new Button(LoadBase) { text = "Remove local data" }); var element = new InspectorElement(local); foldout.Add(element); } return(foldout); }
private VisualElement GetBaseDataElement() { var foldout = new Foldout { text = "Base data", value = false, contentContainer = { style = { marginLeft = 5 } } }; foldout.Add(GetContextSystemsElement()); foldout.Add(GetSystemsElement()); foldout.Add(GetEditorSystemsElement()); return(foldout); }
private VisualElement GetSystemsElement() { var foldout = new Foldout { text = "Systems", value = false, contentContainer = { style = { marginLeft = 5 } } }; foldout.Add(GetBaseSystemsOrderElement()); foldout.Add(GetBaseUpdateSystemsOrderElement()); foldout.Add(GetBaseSystemsSettingsElement()); return(foldout); }
void AddDescGroup( List <CodeGenDescription> descList, VisualElement elementAddTo, string groupLabel, bool open, VisualElement targetElement) { var group = new Foldout(); var savedColor = GUI.backgroundColor; group.style.backgroundColor = Color.gray; group.value = open; group.text = groupLabel; var eventFields = new VisualElement(); foreach (var type in descList) { var field = new TextField(type.DisplayEventTypeName); field.style.backgroundColor = savedColor; field.isReadOnly = true; field.value = editorWindowCodeBuilder.ContainsCallback(type.CallbackMethodName) ? type.CallbackMethodName : string.Empty; var doubleClickManipulator = new MouseDoubleClickManipulator() .RegisterDoubleClick(() => { field.value = type.CallbackMethodName; GenerateCode(type); }); field.AddManipulator(doubleClickManipulator); eventFields.Add(field); } group.Add(eventFields); var warnLabel = new Label("Set the VisualElement name."); warnLabel.visible = false; group.Add(warnLabel); group.schedule.Execute(_ => { var isEnabled = !string.IsNullOrEmpty(targetElement.name); scrollView.SetEnabled(isEnabled); eventFields.visible = isEnabled; warnLabel.visible = !isEnabled; }).Every(100); elementAddTo.Add(group); }
public override VisualElement CreatePropertyGUI(SerializedProperty property) { var root = new Foldout { text = property.displayName }; root.Add(new PropertyField(property.FindPropertyRelative("startFollowers"))); root.Add(new PropertyField(property.FindPropertyRelative("startCredibility"))); root.Add(new PropertyField(property.FindPropertyRelative("startPositivity"))); root.Add(new PropertyField(property.FindPropertyRelative("basePostImpact"))); root.Add(UITools.CreateScenarioEndingList(property.FindPropertyRelative("scenarioSettings"), "Scenario Settings", true)); return(root); }
protected override VisualElement Repaint(SerializedProperty property) { var container = new Foldout() { text = property.displayName }; var typeName = property.FindPropertyRelative("lhsTypeName"); var memberName = property.FindPropertyRelative("lhsMemberName"); container.Add(CreateTypePopup(typeName)); container.Add(CreatePropertyPopup(memberName, typeName.stringValue)); return(container); }
private void AddNewSingleEntryToFoldout(Foldout foldout, string entryText = "") { var newIncludeNameStartsWithVisualElement = new VisualElement(); newIncludeNameStartsWithVisualElement.style.flexDirection = new StyleEnum <FlexDirection>(FlexDirection.Row); var newIncludeNameStartsWithTextField = new TextField { value = entryText }; newIncludeNameStartsWithTextField.style.flexGrow = 1; var newIncludeNameStartsWithButton = new Button() { text = "X" }; newIncludeNameStartsWithButton.style.borderTopLeftRadius = 0; newIncludeNameStartsWithButton.style.borderTopRightRadius = 0; newIncludeNameStartsWithButton.style.borderBottomRightRadius = 0; newIncludeNameStartsWithButton.style.borderBottomLeftRadius = 0; newIncludeNameStartsWithButton.clickable.clicked += () => RemoveVisualElementFromFoldout( newIncludeNameStartsWithVisualElement, foldout); newIncludeNameStartsWithVisualElement.Add(newIncludeNameStartsWithButton); newIncludeNameStartsWithVisualElement.Add(newIncludeNameStartsWithTextField); foldout.Add(newIncludeNameStartsWithVisualElement); }
private void DoLabelsDisplay() { m_LabelsFoldOut = new Foldout { text = L10n.Tr("Labels"), name = k_LabelsFoldOutName, classList = { k_FoldoutClass } }; var i = 0; foreach (var label in m_Labels) { var toggle = new Toggle(L10n.Tr(label)) { name = label, classList = { k_ToggleClass } }; toggle.RegisterValueChangedCallback(evt => { if (evt.newValue) { // Uncheck Unlabeled if checked m_StatusFoldOut.Q <Toggle>(PageFilters.k_UnlabeledStatus.ToLower()).value = false; } UpdateFiltersIfNeeded(); }); m_LabelsFoldOut.Add(toggle); if (++i > k_MaxDisplayLabels) { UIUtils.SetElementDisplay(toggle, false); } } m_LabelsFoldOut.Query <Label>().ForEach(UIUtils.TextTooltipOnSizeChange); m_Container.Add(m_LabelsFoldOut); }
public void Refresh() { m_ScrollView.Clear(); var l = AssetDatabase.GetAllAssetPaths() .Where(p => p.StartsWith("Assets/Examples/Editor/PrefabExplorer") && p.EndsWith("prefab")).ToList(); l.Sort(); foreach (string path in l) { var image = new Image() { style = { width = TextureSize, height = TextureSize }, userData = path }; var f = new Foldout() { text = path, value = false, viewDataKey = path // this makes sure to restore expanded state after domain reload }; f.Add(image); m_ScrollView.Add(f); } }
private VisualElement CreateShaderProperties(ShaderProgramPerfInfo info) { Foldout fold = new Foldout(); fold.text = "Shader Property"; fold.name = "ShaderInfo"; var val = new string[2, 6]; val[0, 0] = "Has uniform computation"; val[0, 1] = "Has side-effects"; val[0, 2] = "Modifies coverage"; val[0, 3] = "Use late ZS test"; val[0, 4] = "Use late ZS update"; val[0, 5] = "Read color buffer"; val[1, 0] = info.hasUniformComputation.ToString(); val[1, 1] = info.hasSideEffects.ToString(); val[1, 2] = info.modifisCoverage.ToString(); val[1, 3] = info.useLateZSTest.ToString(); val[1, 4] = info.useLateZSUpdate.ToString(); val[1, 5] = info.readColorBuffer.ToString(); fold.Add(CreateTableView(val)); return(fold); }
private void PopulateTags(bool isOpen) { Foldout tagsFoldout = rootVisualElement.Q <Foldout>("TagsFoldout"); tagsFoldout.SetValueWithoutNotify(isOpen); tagsFoldout.Clear(); ListView listView = CreateListViewForTags(); tagsFoldout.Add(listView); List <ScriptableTag> tags = ScriptableSettingsManager.Instance.Tags; for (int i = 0; i < tags.Count; i++) { Toggle toggle = new Toggle(); toggle.text = " " + tags[i].name; int index = i; toggle.RegisterValueChangedCallback(x => OnToggleTag(tags[index], x)); ContextualMenuManipulator manipulator = new ContextualMenuManipulator(x => { x.menu.AppendAction("Delete", y => DeleteTag(tags[index])); }) { target = toggle }; listView.Add(toggle); } listView.style.height = Mathf.Min(tags.Count * 20, 100); Button tagsAdd = rootVisualElement.Q <Button>("TagsAdd"); tagsAdd.clicked -= GoToCreateNewTag; tagsAdd.clicked += GoToCreateNewTag; }
private void RebuildDetails() { CustomDetailRoot.Clear(); DefaultLabel.Clear(); var bifurcationsProp = CommandItem.CommandProperty.GetChildProperty("bifurcations"); var count = bifurcationsProp.GetProperty().arraySize; for (int i = 0; i < count; i++) { var bifurcationBox = new VisualElement(); var item = bifurcationsProp.GetArrayElementAt(i); var labelProp = item.GetChildProperty("label").GetProperty(); var a = new Foldout(); a.text = $"「{labelProp.stringValue}」"; // new Label($"「{labelProp.stringValue}」"); var toggle = a.Q <Toggle>(); toggle.style.marginBottom = 0f; a.style.marginTop = 10f; toggle.style.backgroundColor = new Color(0, 0, 0, 0.5f); bifurcationBox.Add(a); DefaultLabel.Add(a); var l = new CommandListView(CommandItem.ParentList, item.GetChildProperty("commandList.commands")); a.Add(l); CustomDetailRoot.Add(bifurcationBox); } }
private VisualElement CreateFoldout(SerializedProperty property) { property = property.Copy(); Foldout e = new Foldout(); e.text = "TEST FOLDOUT"; e.value = property.isExpanded; e.bindingPath = property.propertyPath; e.name = "unity-foldout-" + property.propertyPath; Label label = e.Q <Toggle>((string)null, Foldout.toggleUssClassName).Q <Label>((string)null, Toggle.textUssClassName); label.bindingPath = property.propertyPath; SerializedProperty endProperty = property.GetEndProperty(); property.NextVisible(true); while (!SerializedProperty.EqualContents(property, endProperty)) { PropertyField propertyField = new PropertyField(property); propertyField.name = "unity-property-field-" + property.propertyPath; if (propertyField != null) { e.Add((VisualElement)propertyField); } if (!property.NextVisible(false)) { break; } } return((VisualElement)e); }
private void OnEnable() { rootVisualElement.styleSheets.Add(Resources.Load <StyleSheet>("ItemEditor_DatabaseView_Style")); ItemDatabase itemDatabase = AssetDatabase.LoadAssetAtPath("Assets/Scripts/Inventory/Objects/ItemDatabase.asset", typeof(ItemDatabase)) as ItemDatabase; rootVisualElement.Clear(); var visualTree = Resources.Load <VisualTreeAsset>(databaseViewerPath); visualTree.CloneTree(rootVisualElement); VisualElement fieldContainer = rootVisualElement.Q(name: "item-object-field-container"); Foldout itemFoldOut = rootVisualElement.Q(name: "item-foldout") as Foldout; var objectFieldTemplate = Resources.Load <VisualTreeAsset>(objectFieldTemplatePath); foreach (BaseItem item in itemDatabase.items) { VisualElement itemObject = objectFieldTemplate.CloneTree(); ObjectField itemObjectField = itemObject.Q(name: "item-object-field") as ObjectField; itemObjectField.objectType = typeof(BaseItem); itemObjectField.value = item; itemObjectField.label = item.itemName; itemFoldOut.Add(itemObject); } }
protected override void DoDisplay() { m_StatusFoldOut = new Foldout { text = L10n.Tr("Status"), name = k_StatusFoldOutName, classList = { k_FoldoutClass } }; foreach (var status in k_Statuses) { var toggle = new Toggle(status) { name = status.ToLower(), classList = { k_ToggleClass } }; toggle.RegisterValueChangedCallback(evt => { if (evt.newValue) { foreach (var t in m_StatusFoldOut.Children().OfType <Toggle>()) { if (t == toggle) { continue; } t.SetValueWithoutNotify(false); } } UpdateFiltersIfNeeded(); }); m_StatusFoldOut.Add(toggle); } m_Container.Add(m_StatusFoldOut); }
void Reload() { foldout.Clear(); lengthField = new IntegerField("Count"); lengthField.SetValueWithoutNotify(value.Count); lengthField.RegisterCallback <KeyDownEvent>(ChangeCount); foldout.Add(lengthField); for (int i = 0; i < value.Count; i++) { int j = i; foldout.Add(ElementExtension.DrawField("element " + j, typeof(E), value[j], _newValue => { value[j] = (E)_newValue; })); } }
public VisualElement Draw( object source, Type type, string label = "", Action <object> onValueChanged = null) { var title = string.IsNullOrEmpty(label) ? "content" : label; if (source == null) { title = $"{title} [EMPTY]"; } var container = new Foldout() { text = title, value = false, style = { paddingLeft = 4, color = new StyleColor(Color.black), backgroundColor = new StyleColor(new Color(0.5f, 0.5f, 0.5f)) } }; #if ODIN_INSPECTOR container.Add(new IMGUIContainer(() => source.DrawOdinPropertyInspector())); #endif return(container); }
private VisualElement CreateFoldout(SerializedProperty property) { property = property.Copy(); var foldout = new Foldout() { text = property.localizedDisplayName }; foldout.value = property.isExpanded; foldout.bindingPath = property.propertyPath; foldout.name = "Foldout:" + property.propertyPath; var endProperty = property.GetEndProperty(); property.NextVisible(true); // Expand the first child. do { if (SerializedProperty.EqualContents(property, endProperty)) { break; } var field = new PropertyField(property); field.m_ParentPropertyField = this; field.name = "PropertyField:" + property.propertyPath; if (field == null) { continue; } foldout.Add(field); }while (property.NextVisible(false)); // Never expand children. return(foldout); }
private void UpdateData(string text) { this.container.Clear(); var lines = text.Split('\n'); Foldout foldout = null; for (int i = 0; i < lines.Length; ++i) { var line = lines[i]; if (line.StartsWith("### ") == true) { // Begin Q-A var v = new Foldout(); v.value = false; v.text = line.Substring(4); this.container.Add(v); foldout = v; } else if (foldout != null) { if (line.Trim().Length > 0) { var match = System.Text.RegularExpressions.Regex.Match(line, "<answer>(.*?)</answer>"); var val = match.Groups[1].Value; var label = new Label(); label.AddToClassList("answer"); label.text = val; foldout.Add(label); } } } }
public override VisualElement CreatePropertyGUI(SerializedProperty property) { var root = new Foldout { value = property.isExpanded, text = property.displayName }; root.RegisterValueChangedCallback(evt => property.isExpanded = evt.newValue); var name = new TextField("Shared Group Name"); name.BindProperty(property.FindPropertyRelative("m_SharedGroupName")); root.Add(name); var group = new ObjectField("Shared Group") { allowSceneObjects = false, objectType = typeof(AddressableAssetGroup) }; var groupProperty = property.FindPropertyRelative("m_SharedGroup"); group.BindProperty(groupProperty); group.RegisterValueChangedCallback(evt => name.style.display = evt.newValue != null ? DisplayStyle.None : DisplayStyle.Flex); name.style.display = groupProperty.objectReferenceValue != null ? DisplayStyle.None : DisplayStyle.Flex; root.Add(group); var localeName = new TextField("Locale Group Name"); localeName.BindProperty(property.FindPropertyRelative("m_LocaleGroupNamePattern")); root.Add(localeName); var localeGroupsProperty = property.FindPropertyRelative("m_LocaleGroups"); var list = new ReorderableList(localeGroupsProperty) { CreateItemCallback = CreateItem, AddCallback = ShowAddItemMenu, RemoveCallback = RemoveItem, ReorderCallback = MoveItem }; root.Add(list); var readOnly = new Toggle("Read Only"); readOnly.BindProperty(property.FindPropertyRelative("m_MarkEntriesReadOnly")); root.Add(readOnly); return(root); }
private void AddOption(string name, bool enableMultiSelect) { var container = new Foldout(); container.text = name; var input = AddInput(container.contentContainer, "Source", enableMultiSelect, name); var output = AddOutput(container.contentContainer, "Destination", name); var button = new Button(); button.text = "Convert"; button.style.flexGrow = 1; button.style.marginBottom = 25; button.SetEnabled(false); container.Add(button); this.rootVisualElement.Add(container); input.RegisterValueChangedCallback(evt => { UpdateButtonState(button, input, output); }); output.RegisterValueChangedCallback(evt => { UpdateButtonState(button, input, output); }); button.clicked += () => { if (enableMultiSelect) { var selection = Directory.GetFiles(input.value, "*.T3D", SearchOption.AllDirectories); if (selection.Length == 0) { EditorUtility.DisplayDialog("Selection Problem", "Source directory does not contain any T3D files", "OK"); } else { ProcessSelection(selection, input.value, output.value); } } else { if (!File.Exists(input.value)) { EditorUtility.DisplayDialog("Selection Problem", "Source file does not exist", "OK"); } else { ProcessSelection(new string[] { input.value }, input.value, output.value); } } }; UpdateButtonState(button, input, output); }
private VisualElement GetSystemsFoldoutElement() { var foldout = new Foldout { text = "Systems", value = false, contentContainer = { style = { marginLeft = 5 } } }; foldout.Add(GetSceneObjetsOrderElement()); foldout.Add(GetUpdateOrderElement()); foldout.Add(GetSystemSettingsElement()); foldout.Add(GetEditorSystemDataElement()); return(foldout); }