void CreatePopup() { int channelCount = SlotValueHelper.GetChannelCount(m_Node.FindSlot <MaterialSlot>(m_SlotId).concreteValueType); if (m_PopupField != null) { if (channelCount == m_PreviousChannelCount) { return; } Remove(m_PopupField); } m_PreviousChannelCount = channelCount; List <string> popupEntries = new List <string>(); for (int i = 0; i < channelCount; i++) { popupEntries.Add(m_ValueNames[i]); } var value = (int)m_PropertyInfo.GetValue(m_Node, null); if (value >= channelCount) { value = 0; } m_PopupField = new PopupField <string>(popupEntries, value); m_PopupField.OnValueChanged(OnValueChanged); Add(m_PopupField); }
private void UpdatePresetField() { var presetParent = rootVisualElement.Q <VisualElement>("Preset"); presetParent.Clear(); PresetData.LoadPresets(this.currentTypeInfo.type, this.presetList); if (this.presetList.Count > 0) { presetPopup = new PopupField <PresetData>(this.presetList, 0, PresetDataToString, PresetDataToString); #if UNITY_2019_1_OR_NEWER || UNITY_2019_OR_NEWER presetPopup.RegisterValueChangedCallback((val) => { this.currentPreset = val.newValue; }); #else presetPopup.OnValueChanged((val) => { this.currentPreset = val.newValue; }); #endif currentPreset = this.presetList[0]; presetParent.Add(presetPopup); } }
public DiffusionProfileSlotControlView(DiffusionProfileInputMaterialSlot slot) { AddStyleSheetPath("DiffusionProfileSlotControlView"); m_Slot = slot; popupField = new PopupField <string>(m_Slot.diffusionProfile.popupEntries, m_Slot.diffusionProfile.selectedEntry); popupField.OnValueChanged(OnValueChanged); Add(popupField); }
private void OnEnable() { _rootView = this.GetRootVisualContainer(); _rootView.Add(new Label("Midi Settings") { style = { fontSize = 18, marginTop = 10, marginBottom = 10, } }); // Container for Device Name label and field VisualContainer deviceNameContainer = new VisualContainer() { style = { flexDirection = FlexDirection.Row } }; _rootView.Add(deviceNameContainer); // Label for Field deviceNameContainer.Add(new Label("Device Name")); // Input Name Field _deviceNameField = new TextField() { isDelayed = true, value = EditorPrefs.GetString(DEVICE_NAME_STRING), style = { flexGrow = 1 }, }; _deviceNameField.OnValueChanged(evt => EditorPrefs.SetString(DEVICE_NAME_STRING, evt.newValue)); //deviceNameContainer.Add(_deviceNameField); // Get available device names VRCPortMidiInput midi = new VRCPortMidiInput(); var deviceNames = midi.GetDeviceNames().ToList(); // Add blank device name to use if specified device not found deviceNames.Insert(0, ""); string currentDeviceValue = EditorPrefs.GetString(DEVICE_NAME_STRING); string defaultValue = deviceNames.Contains(currentDeviceValue) ? currentDeviceValue : ""; // Create and add device popup var deviceNamePopupField = new PopupField <string>(deviceNames, defaultValue) { style = { flexGrow = 1 }, name = "midiDevicePopUp", }; deviceNamePopupField.OnValueChanged(evt => EditorPrefs.SetString(DEVICE_NAME_STRING, evt.newValue)); deviceNameContainer.Add(deviceNamePopupField); }
public PackageView(AvailablePackage package) { this.package = package; style.height = 32; style.flexDirection = FlexDirection.Row; style.marginBottom = style.marginTop = style.marginLeft = style.marginRight = 4; style.alignItems = Align.Center; style.borderRadius = 4; packageName = new Label(package.Name); packageName.style.fontSize = FontSizes.packageRow; packageName.style.flex = 1; packageName.style.textColor = Colors.packageRowText; versionSelector = new PopupField <string>(package.Versions.ToList(), package.Versions.Last()); versionSelector.style.width = 100; versionSelector.style.height = 24; versionSelector.style.paddingRight = 12; versionSelector.style.textAlignment = TextAnchor.MiddleCenter; versionSelector.style.fontSize = FontSizes.packageRow; versionSelector.OnValueChanged(HandleVersionSelectorValueChanged); infoButton = new Button(HandleInfoClicked); infoButton.style.width = 40; infoButton.text = "Info"; installButton = new Button(HandleInstallClicked); installButton.style.width = 60; installButton.text = "Install"; switchVersionButton = new Button(HandleSwitchVersionClicked); switchVersionButton.style.width = 60; switchVersionButton.text = "Install"; installedLabel = new Label("Installed"); installedLabel.style.width = 60; installedLabel.style.fontSize = FontSizes.packageRow; installedLabel.style.textColor = Colors.packageRowText; removeButton = new Button(HandleRemoveClicked); removeButton.style.width = 30; removeButton.text = "X"; style.backgroundColor = Colors.packageRowBackground; isPackageInstalled = BindToDerivedState(packages.InstalledPackages, installedPackages => installedPackages.Packages.Any(p => p.Name == package.Name)); Init(); }
private void UpdateBonePopup(string[] names) { if (m_BonePopup != null) { m_BonePopup.RemoveFromHierarchy(); } m_BonePopup = new PopupField <string>(new List <string>(names), 0); m_BonePopup.name = "BonePopupField"; m_BonePopup.OnValueChanged((evt) => { bonePopupChanged(boneIndex); }); m_BonePopupContainer.Add(m_BonePopup); }
public LayerFieldSlotControlView(LayerSlot slot) { #if UNITY_EDITOR var options = new List <KeyValuePair <int, string> >(); for (int i = 0; i <= 31; i++) { var layerN = LayerMask.LayerToName(i); if (layerN.Length > 0) { options.Add(new KeyValuePair <int, string>(i, layerN)); } } var layerField = new PopupField <KeyValuePair <int, string> >(options, options.FindIndex(p => p.Key == slot.value)); layerField.OnValueChanged(e => { slot.value = e.newValue.Key; }); Add(layerField); #endif }
public PopupControlView(string label, AbstractMaterialNode node, PropertyInfo propertyInfo) { AddStyleSheetPath("Styles/Controls/PopupControlView"); m_Node = node; m_PropertyInfo = propertyInfo; Type type = propertyInfo.PropertyType; if (type != typeof(PopupList)) { throw new ArgumentException("Property must be a PopupList.", "propertyInfo"); } Add(new Label(label ?? ObjectNames.NicifyVariableName(propertyInfo.Name))); var value = (PopupList)propertyInfo.GetValue(m_Node, null); m_PopupField = new PopupField <string>(value.popupEntries, value.selectedEntry); m_PopupField.OnValueChanged(OnValueChanged); Add(m_PopupField); }
internal ExportTextureNode() : base() { title = "Export Texture"; capabilities &= ~Capabilities.Deletable; AddInputPort <Vector4>("Color"); RefreshPorts(); m_WidthPopupField = new PopupField <int>(s_PopupValues, defaultValue: s_PopupValues[6]) { name = "Width" }; m_HeightPopupField = new PopupField <int>(s_PopupValues, defaultValue: s_PopupValues[6]) { name = "Height" }; m_HeightPopupField.SetEnabled(false); m_WidthPopupField.OnValueChanged(OnWidthValueChanged); extensionContainer.Add(UIElementsUtility.CreateLabeledElement("Width", m_WidthPopupField)); extensionContainer.Add(UIElementsUtility.CreateLabeledElement("Height", m_HeightPopupField)); RefreshExpandedState(); }
private void InitConfigType() { if (this.typeInfoList == null || this.typeInfoList.Count <= 0) { return; } var configType = rootVisualElement.Q <VisualElement>("ConfigType"); configTypePopup = new PopupField <Utility.TypeAndAttr>(this.typeInfoList, 0, TypeAndAttrToString, TypeAndAttrToString); currentTypeInfo = typeInfoList[0]; #if UNITY_2019_1_OR_NEWER || UNITY_2019_OR_NEWER configTypePopup.RegisterValueChangedCallback((val) => { OnChangedSelectConfig(val); }); #else configTypePopup.OnValueChanged((val) => { OnChangedSelectConfig(val); }); #endif configType.Add(configTypePopup); this.ApplyToTypeInfo(currentTypeInfo); }