public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            var container = new VisualElement();

            var keyProperty    = property.FindPropertyRelative("key");
            var targetProperty = keyProperty.FindPropertyRelative("target");
            var targetChoices  = new List <Target> {
                Target.Global, Target.Item
            };
            var targetField = new PopupField <Target>("Target", targetChoices, (Target)targetProperty.enumValueIndex);
            var keyField    = new PropertyField(keyProperty.FindPropertyRelative("key"));

            var itemContainer = CreateItemContainer(property.FindPropertyRelative("item"));

            void SwitchDisplayItem(Target target)
            {
                itemContainer.SetVisibility(target == Target.Item);
            }

            targetField.RegisterValueChangedCallback(e =>
            {
                targetProperty.enumValueIndex = (int)e.newValue;
                property.serializedObject.ApplyModifiedProperties();
                SwitchDisplayItem(e.newValue);
            });

            SwitchDisplayItem((Target)targetProperty.enumValueIndex);

            container.Add(targetField);
            container.Add(keyField);
            container.Add(itemContainer);

            return(container);
        }
Beispiel #2
0
        public void UpdateDropdownEntries()
        {
            if (node is SubGraphNode subGraphNode && subGraphNode.asset != null)
            {
                m_DropdownItems.Clear();
                var dropdowns = subGraphNode.asset.dropdowns;
                foreach (var dropdown in dropdowns)
                {
                    if (dropdown.isExposed)
                    {
                        var name = subGraphNode.GetDropdownEntryName(dropdown.referenceName);
                        if (!dropdown.ContainsEntry(name))
                        {
                            name = dropdown.entryName;
                            subGraphNode.SetDropdownEntryName(dropdown.referenceName, name);
                        }

                        var field = new PopupField <string>(dropdown.entries.Select(x => x.displayName).ToList(), name);
                        field.RegisterValueChangedCallback(evt =>
                        {
                            subGraphNode.owner.owner.RegisterCompleteObjectUndo("Change Dropdown Value");
                            subGraphNode.SetDropdownEntryName(dropdown.referenceName, field.value);
                            subGraphNode.Dirty(ModificationScope.Topological);
                        });

                        m_DropdownItems.Add(new PropertyRow(new Label(dropdown.displayName)), (row) =>
                        {
                            row.styleSheets.Add(Resources.Load <StyleSheet>("Styles/PropertyRow"));
                            row.Add(field);
                        });
                    }
                }
            }
        }
Beispiel #3
0
        public override VisualElement CreateInspectorGUI()
        {
            var root   = new VisualElement();
            var system = target as UIElementsEventSystem;

            var defaultSelection = system.sendIMGUIEvents ? m_EventGenerationChoices[1] : m_EventGenerationChoices[0];

            inputEventsField = new PopupField <string>("Event Generation", m_EventGenerationChoices, defaultSelection);
            inputEventsField.RegisterValueChangedCallback((evt) => OnPopupValueChanged(evt));
            root.Add(inputEventsField);

            var serializedProperty = serializedObject.FindProperty("m_SendNavigationEvents");

            SendNavigationField = new PropertyField(serializedProperty);
            root.Add(SendNavigationField);

            //TODO: Group Navigation events parameters together in a foldout and toggle visibility when navigation is enabled
            //TODO: Group Input delay and repeat together and only show when sendInputEvents is selected.
            while (serializedProperty.Next(false))
            {
                root.Add(new PropertyField(serializedProperty));
            }

            inputEventsField.schedule.Execute(() => UpdatePopupFieldValues()).Every(100);
            UpdateNavigationFieldVisibility();
            return(root);
        }
        private VisualElement CreateLevelCategoryField(ChapterNode chapterNode)
        {
            var levelNames = GameFrameworkSettings.Database.GetGameData <DefaultLevelCategoriesSO>(3).ArchetypeNames;

            levelNames = EditorUtilities.GetNoneSelectableFrom(levelNames);

            PopupField <string> field = new PopupField <string>(
                "Level Category", levelNames.ToList(), 0)
            {
                index = chapterNode.LevelScene.levelCategory + 1
            };

            field.RegisterValueChangedCallback((v) => {
                owner.RegisterCompleteObjectUndo("Updated chapterNode levelCategory");
                var val                = chapterNode.LevelScene;
                val.levelCategory      = field.index - 1;
                chapterNode.LevelScene = val;

                var veIdx = controlsContainer.IndexOf(_levelSceneField);
                controlsContainer.RemoveAt(veIdx);

                _levelSceneField = CreateLevelSceneField(chapterNode);
                controlsContainer.Insert(veIdx, _levelSceneField);
            });

            return(field);
        }
Beispiel #5
0
    void CreateVisualTree()
    {
        var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/EditorComponents/ObjectManager.uxml");
        var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/Editor/LevelEditorWindow.uss");

        objectEditor = visualTree.CloneTree();

        objectPropertiesContainer = objectEditor.Q <Box>("addObjectContainer");
        objectTypeContainer       = objectEditor.Q <Box>("addObjectTypeContainer");

        ObjectNameTextField = objectPropertiesContainer.Q <TextField>("objectNameTextField");
        AddObjectButton     = objectPropertiesContainer.Q <Button>("addObjectNameButton");
        AddObjectButton.RegisterCallback <MouseUpEvent>(AddNewObject);
        SaveObjectButton = objectPropertiesContainer.Q <Button>("saveObjectNameButton");
        SaveObjectButton.RegisterCallback <MouseUpEvent>(SaveEditedObject);

        ObjectTypeLayer = new PopupField <string>("Select Type Of Object", ObjectTypes, 0);
        ObjectTypeLayer.RegisterValueChangedCallback(UpdateOnTypeSelection);
        ObjectTypeLayer.Focus();
        //ObjectTypeLayer.AddToClassList("height-width-slider");
        objectTypeContainer.Add(ObjectTypeLayer);

        objectEditContainer          = objectEditor.Q <Box>("editObjectContainer");
        objectEditSelectionContainer = objectEditor.Q <Box>("editObjectSelectionContainer");

        objectSelectionField = new ObjectField {
            objectType = typeof(SpriteObject)
        };
        objectSelectionField.RegisterValueChangedCallback(UpdateOnObjectSelection);

        //objectPropertiesContainer.Add(ObjectTypeLayer);
        objectEditContainer.Add(objectSelectionField);
        objectEditContainer.Add(objectEditSelectionContainer);
    }
Beispiel #6
0
        void UpdatePopups(SkinnedMeshRenderer[] skinnedMeshRenderers, int targetBoneIndex = 0, int mergeWeightTargetBoneIndex = 0)
        {
            if (targetBonePopup != null)
            {
                targetBonePopup.UnregisterValueChangedCallback(OnTargetBoneChanged);
                popupsPlaceholder.Remove(targetBonePopup);
                targetBonePopup = null;
            }

            if (mergeWeightTargetBonePopup != null)
            {
                popupsPlaceholder.Remove(mergeWeightTargetBonePopup);
                mergeWeightTargetBonePopup = null;
            }

            if (skinnedMeshRenderers == null)
            {
                return;
            }

            var bones = skinnedMeshRenderers.SelectMany(r => r.bones).Distinct().ToList();

            targetBonePopup = new PopupField <Transform>("Target bone",
                                                         bones,
                                                         Math.Min(bones.Count, targetBoneIndex),
                                                         t => t.name);
            targetBonePopup.RegisterValueChangedCallback(OnTargetBoneChanged);
            popupsPlaceholder.Add(targetBonePopup);

            mergeWeightTargetBonePopup = new PopupField <Transform>("Merge bone weight into",
                                                                    bones,
                                                                    Math.Min(bones.Count, mergeWeightTargetBoneIndex),
                                                                    t => t.name);
            popupsPlaceholder.Add(mergeWeightTargetBonePopup);
        }
        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.RegisterValueChangedCallback(OnValueChanged);
            Add(m_PopupField);
        }
        protected VisualElement CreatePropertyPopup(SerializedProperty property, string typeName)
        {
            var type    = string.IsNullOrEmpty(typeName) ? null : TaskUtility.GetTypeWithinAssembly(typeName);
            var choices = GetBehaviorProperties(type).Select(x => x.Name).ToList();

            choices.Insert(0, "None");

            var name = string.IsNullOrEmpty(property.stringValue) ? "None" : property.stringValue;

            if (!choices.Contains(name))
            {
                name = choices.First();
            }

            var popup = new PopupField <string>(choices, name);

            popup.label = property.displayName;
            popup.RegisterValueChangedCallback(ev =>
            {
                property.stringValue = ev.newValue == "None" ? null : ev.newValue;
                property.serializedObject.ApplyModifiedProperties();
                property.serializedObject.Update();
                CreatePropertyGUI(Property);
            });
            return(popup);
        }
        public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            var assemblyQualifiedNameProperty = property.FindPropertyRelative("assemblyQualifiedName");
            var assemblyQualifiedName         = string.IsNullOrEmpty(assemblyQualifiedNameProperty.stringValue) ? string.Empty : assemblyQualifiedNameProperty.stringValue;
            var types = GetTypes();

            types.Insert(0, default);
            var initial = new SerializableType(Type.GetType(assemblyQualifiedName, false));

            if (!types.Contains(initial) || !initial.IsCreated)
            {
                assemblyQualifiedNameProperty.stringValue = string.Empty;
                property.serializedObject.ApplyModifiedProperties();
                initial = default;
            }
            var field = new PopupField <SerializableType>(property.displayName, types, initial, t => string.IsNullOrWhiteSpace(t.AssemblyQualifiedName) ? NO_TYPE : t.AssemblyQualifiedName.Substring(0, t.AssemblyQualifiedName.IndexOf(',')), t => string.IsNullOrWhiteSpace(t.AssemblyQualifiedName) ? NO_TYPE : t.AssemblyQualifiedName.Substring(0, t.AssemblyQualifiedName.IndexOf(',')).Replace('.', '/'));

            field.RegisterValueChangedCallback(evt =>
            {
                property.FindPropertyRelative("assemblyQualifiedName").stringValue = evt.newValue.AssemblyQualifiedName;
                property.serializedObject.ApplyModifiedProperties();
            });

            return(field);
        }
Beispiel #10
0
        void InitializeLabelingSchemes(VisualElement parent)
        {
            //this function should be called only once during the lifecycle of the editor element
            AssetLabelingScheme labelingScheme = new AssetNameLabelingScheme();

            if (AreSelectedAssetsCompatibleWithAutoLabelScheme(labelingScheme))
            {
                m_LabelingSchemes.Add(labelingScheme);
            }

            labelingScheme = new AssetFileNameLabelingScheme();
            if (AreSelectedAssetsCompatibleWithAutoLabelScheme(labelingScheme))
            {
                m_LabelingSchemes.Add(labelingScheme);
            }

            labelingScheme = new CurrentOrParentsFolderNameLabelingScheme();
            if (AreSelectedAssetsCompatibleWithAutoLabelScheme(labelingScheme))
            {
                m_LabelingSchemes.Add(labelingScheme);
            }

            var descriptions = m_LabelingSchemes.Select(scheme => scheme.Description).ToList();

            descriptions.Insert(0, "<Select Scheme>");
            m_LabelingSchemesPopup = new PopupField <string>(descriptions, 0)
            {
                label = "Labeling Scheme"
            };
            m_LabelingSchemesPopup.style.marginLeft = 0;
            parent.Add(m_LabelingSchemesPopup);

            m_LabelingSchemesPopup.RegisterValueChangedCallback(evt => AssignAutomaticLabelToSelectedAssets());
        }
        public static VisualElement CreateAsStringPopupField <TEnum>(SerializedProperty property, Action <TEnum> onValueChanged = null)
            where TEnum : struct, Enum
        {
            Assert.AreEqual(property.propertyType, SerializedPropertyType.Enum);
#if UNITY_2019_3_OR_NEWER
            var enumField = new UnityEditor.UIElements.EnumField
            {
                bindingPath = property.propertyPath
            };
            enumField.RegisterValueChangedCallback(e =>
            {
                if (onValueChanged != null && e.newValue is TEnum newValue)
                {
                    onValueChanged.Invoke(newValue);
                }
            });
            enumField.Bind(property.serializedObject);
            return(enumField);
#else
            // HACK: `Field type UnityEditor.UIElements.EnumField is not compatible with Enum property "myEnum"` in 2019.2
            // ref: https://forum.unity.com/threads/cant-create-bindings-for-an-enum-not-compatible.728111/#post-4873661
            var enumField = new PopupField <string>
            {
                bindingPath = property.propertyPath
            };
            // HACK: `NullReferenceException: Object reference not set to an instance of an object` in 2019.2
            enumField.RegisterValueChangedCallback(_ =>
            {
                onValueChanged?.Invoke((TEnum)(object)enumField.index);
            });
            return(enumField);
#endif
        }
        private VisualElement CreateWorldField(ChapterNode chapterNode)
        {
            var worldNames = GameFrameworkSettings.Database.GetGameData <DefaultWorldsSO>(2).ArchetypeNames;

            worldNames = EditorUtilities.GetNoneSelectableFrom(worldNames);

            PopupField <string> field = new PopupField <string>(
                "World", worldNames.ToList(), 0)
            {
                index = chapterNode.WorldScene.world + 1
            };

            field.RegisterValueChangedCallback((v) => {
                owner.RegisterCompleteObjectUndo("Updated chapterNode world");
                var val   = chapterNode.WorldScene;
                val.world = field.index - 1;
                chapterNode.WorldScene = val;

                var veIdx = controlsContainer.IndexOf(_worldSceneField);
                controlsContainer.RemoveAt(veIdx);

                _worldSceneField = CreateWorldSceneField(chapterNode);
                controlsContainer.Insert(veIdx, _worldSceneField);
            });

            return(field);
        }
        private VisualElement CreateLevelSceneField(ChapterNode chapterNode)
        {
            var levelScenes = GameFrameworkSettings.Database.GetGameData <DefaultLevelCategoriesSO>(3).GetSceneNames(chapterNode.LevelScene.levelCategory).ToList();

            if (levelScenes.Count == 0)
            {
                levelScenes = new List <string>()
                {
                    ""
                }
            }
            ;

            PopupField <string> field = new PopupField <string>(
                "Level Scene", levelScenes, 0)
            {
                index = chapterNode.LevelScene.levelScene
            };

            field.RegisterValueChangedCallback((v) => {
                owner.RegisterCompleteObjectUndo("Updated chapterNode levelScene");
                var val                = chapterNode.LevelScene;
                val.levelScene         = field.index;
                chapterNode.LevelScene = val;
            });

            return(field);
        }
Beispiel #14
0
        private void UpdateBonePopup(string[] names)
        {
            VisualElement boneElement = null;

            if (m_ModeField != null && mode == WeightEditorMode.Smooth)
            {
                boneElement = this.Q <VisualElement>("Bone");
                boneElement.SetHiddenFromLayout(false);
            }

            if (m_BonePopup != null)
            {
                m_BonePopupContainer.Remove(m_BonePopup);
            }

            m_BonePopup         = new PopupField <string>(new List <string>(names), 0);
            m_BonePopup.name    = "BonePopupField";
            m_BonePopup.label   = TextContent.bone;
            m_BonePopup.tooltip = TextContent.boneToolTip;
            m_BonePopup.RegisterValueChangedCallback((evt) =>
            {
                bonePopupChanged(boneIndex);
            });
            m_BonePopupContainer.Add(m_BonePopup);

            if (boneElement != null)
            {
                boneElement.SetHiddenFromLayout(true);
            }
        }
Beispiel #15
0
        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);
            }
        }
        static VisualElement CreatePropertyGUI(SerializedProperty property, List <TriggerTarget> targetChoices, Func <TriggerTarget, string> formatTarget)
        {
            var container = new VisualElement();

            var targetProperty = property.FindPropertyRelative("target");

            var currentTarget            = (TriggerTarget)targetProperty.enumValueIndex;
            var selectingTarget          = targetChoices.Contains(currentTarget) ? currentTarget : targetChoices[0];
            var specifiedTargetItemField = new PropertyField(property.FindPropertyRelative("specifiedTargetItem"));

            void SwitchSpecifiedTargetItemField(TriggerTarget itemTriggerTarget)
            {
                specifiedTargetItemField.SetVisibility(itemTriggerTarget == TriggerTarget.SpecifiedItem);
            }

            var targetField = EnumField.Create(targetProperty.displayName, targetProperty, targetChoices, selectingTarget, formatTarget, SwitchSpecifiedTargetItemField);

            targetField.SetEnabled(targetChoices.Count > 1);

            SwitchSpecifiedTargetItemField((TriggerTarget)targetProperty.enumValueIndex);

            var keyField     = new PropertyField(property.FindPropertyRelative("key"));
            var typeProperty = property.FindPropertyRelative("type");
            var typeField    = new PopupField <string>("Parameter Type")
            {
                bindingPath = "type"
            };

            var valueProperty     = property.FindPropertyRelative("value");
            var valueField        = new VisualElement();
            var boolValueField    = new PropertyField(valueProperty.FindPropertyRelative("boolValue"));
            var floatValueField   = new PropertyField(valueProperty.FindPropertyRelative("floatValue"));
            var integerValueField = new PropertyField(valueProperty.FindPropertyRelative("integerValue"));

            valueField.Add(boolValueField);
            valueField.Add(floatValueField);
            valueField.Add(integerValueField);

            void SwitchTriggerValueField(ParameterType parameterType)
            {
                boolValueField.SetVisibility(parameterType == ParameterType.Bool);
                floatValueField.SetVisibility(parameterType == ParameterType.Float);
                integerValueField.SetVisibility(parameterType == ParameterType.Integer);
            }

            typeField.RegisterValueChangedCallback(e =>
            {
                SwitchTriggerValueField((ParameterType)Enum.Parse(typeof(ParameterType), e.newValue));
            });
            SwitchTriggerValueField((ParameterType)typeProperty.enumValueIndex);

            container.Add(targetField);
            container.Add(specifiedTargetItemField);
            container.Add(keyField);
            container.Add(typeField);
            container.Add(valueField);

            return(container);
        }
 public DiffusionProfileSlotControlView(DiffusionProfileInputMaterialSlot slot)
 {
     styleSheets.Add(Resources.Load <StyleSheet>("DiffusionProfileSlotControlView"));
     m_Slot     = slot;
     popupField = new PopupField <string>(m_Slot.diffusionProfile.popupEntries, m_Slot.diffusionProfile.selectedEntry);
     popupField.RegisterValueChangedCallback(RegisterValueChangedCallback);
     Add(popupField);
 }
        public void InitPackageVersionAction(UPMToolExtension upmToolExtension)
        {
            _getGitTagsButton.clicked += () => { upmToolExtension.GetGitTags(_tagsList, ApplyChoices); };

            _versionTagsPopupField.RegisterValueChangedCallback <string>(upmToolExtension.SelectVersion);

            _changeVersionButton.clicked += upmToolExtension.ChangeVersion;
        }
Beispiel #19
0
            public void Initialize(VisualElement rootVisualElement)
            {
                m_Root = UIElementHelpers.LoadTemplate(kBasePath, "StartLiveLinkWindow");
                m_Root.style.flexGrow = 1;

                m_SearchField = m_Root.Q <ToolbarSearchField>(kNamePrefix + "body__search");
                m_SearchField.RegisterValueChangedCallback(evt => FilterConfigurations());

                m_EmptyMessage = m_Root.Q <VisualElement>(kNamePrefix + "body__empty-message");

                m_ConfigurationsListView               = m_Root.Q <ListView>(kNamePrefix + "body__configurations-list");
                m_ConfigurationsListView.makeItem      = CreateBuildConfigurationItemVisualElement;
                m_ConfigurationsListView.bindItem      = BindBuildConfigurationItem;
                m_ConfigurationsListView.itemsSource   = m_FilteredBuildConfigurationViewModels;
                m_ConfigurationsListView.selectionType = SelectionType.Single;


#if UNITY_2020_1_OR_NEWER
                m_ConfigurationsListView.onSelectionChange += OnConfigurationListViewSelectionChange;
                m_ConfigurationsListView.onItemsChosen     += chosenConfigurations => EditBuildConfiguration((BuildConfigurationViewModel)chosenConfigurations.First());
#else
                m_ConfigurationsListView.onSelectionChanged += OnConfigurationListViewSelectionChanged;
                m_ConfigurationsListView.onItemChosen       += chosenConfiguration => EditBuildConfiguration((BuildConfigurationViewModel)chosenConfiguration);
#endif

                m_AddNewButton          = m_Root.Q <Button>(kNamePrefix + "body__new-build-button");
                m_AddNewButton.clicked += ShowNewBuildNameInput;

                m_NewBuildName          = m_Root.Q <VisualElement>(kNamePrefix + "new-build-name");
                m_NewBuildNameTextField = m_NewBuildName.Q <TextField>();
                m_NewBuildNameSubmit    = m_NewBuildName.Q <Button>(kNamePrefix + "new-build-name__submit");
                m_NewBuildNameTextField.RegisterCallback <KeyDownEvent>(OnNewBuildKeyDown);
                m_NewBuildNameTextField.RegisterCallback <BlurEvent>(OnNewBuildFocusChanged);
                m_NewBuildName.Hide();

                m_BuildMessage = m_Root.Q <VisualElement>(kNamePrefix + "build-message");
                m_BuildMessage.Hide();
                m_ActionButtons     = m_Root.Q <VisualElement>(kNamePrefix + "footer");
                m_StartModeDropdown = new PopupField <StartMode>(sStartModes, StartMode.RunLatestBuild, FormatStartMode, FormatStartMode)
                {
                    style = { flexGrow = 1 }
                };
                m_StartModeDropdown.RegisterValueChangedCallback(OnSelectedStartModeChanged);
                m_ActionButtons.Q <VisualElement>(kNamePrefix + "footer__build-mode-container").Add(m_StartModeDropdown);

                m_StartButton          = m_ActionButtons.Q <Button>(kNamePrefix + "footer__start-button");
                m_StartButton.clicked += () =>
                {
                    m_FooterMessage.Hide();
                    Start(m_StartModeDropdown.value, m_SelectedConfiguration);
                };

                m_FooterMessage = m_Root.Q <VisualElement>(kNamePrefix + "message");
                m_FooterMessage.Hide();

                rootVisualElement.Add(m_Root);
            }
        public NullElement(PropertyElement root, IProperty property, PropertyPath path)
        {
            m_PotentialTypes = new List <Type> {
                typeof(Null)
            };
            binding = this;
            m_Root  = root;
            m_Path  = path;
            name    = m_Path.ToString();

            TypeConstruction.GetAllConstructableTypes <T>(m_PotentialTypes);

            if (typeof(T).IsArray)
            {
                Resources.Templates.NullStringField.Clone(this);
                this.Q <Label>().text = GuiFactory.GetDisplayName(property);
                var button = this.Q <Button>();
                button.text = $"Null ({GetTypeName(typeof(T))})";
                button.clickable.clicked += ReloadWithArrayType;
                if (property.IsReadOnly)
                {
                    button.SetEnabledSmart(false);
                }
                return;
            }

            if (m_PotentialTypes.Count == 2)
            {
                Resources.Templates.NullStringField.Clone(this);
                this.Q <Label>().text = GuiFactory.GetDisplayName(property);
                var button = this.Q <Button>();
                button.text = $"Null ({GetTypeName(typeof(T))})";
                button.clickable.clicked += ReloadWithFirstType;
                if (property.IsReadOnly)
                {
                    button.SetEnabledSmart(false);
                }
                return;
            }

            var typeSelector = new PopupField <Type>(
                GuiFactory.GetDisplayName(property),
                m_PotentialTypes,
                typeof(Null),
                GetTypeName,
                GetTypeName);

            typeSelector.RegisterValueChangedCallback(OnCreateItem);
            if (property.IsReadOnly)
            {
                typeSelector.pickingMode = PickingMode.Ignore;
                typeSelector.Q(className: UssClasses.Unity.BasePopupFieldInput).SetEnabledSmart(false);
            }

            Add(typeSelector);
        }
        public override VisualElement CreateInspectorGUI()
        {
            var root = new VisualElement();

            var button    = (ScreenTransitionButton)target;
            var uiManager = button.GetComponentInParent <UIManager>();
            var screens   = uiManager.GetScreens();

            var nextScreenProperty = serializedObject.FindProperty("nextScreen");

            // Obtain the currently selected screen
            var selectedIndex  = 0;
            var selectedScreen = nextScreenProperty.objectReferenceValue as Screen;

            if (selectedScreen)
            {
                if (screens.Contains(selectedScreen))
                {
                    selectedIndex = screens.IndexOf(selectedScreen);
                }
            }
            else
            {
                nextScreenProperty.objectReferenceValue = screens[0];
                nextScreenProperty.serializedObject.ApplyModifiedProperties();
            }

            string StringFormatCallback(Screen screen) => screen.Name == string.Empty ? "<unnamed>" : screen.Name;

            var popup = new PopupField <Screen>("Next screen", screens, selectedIndex)
            {
                // bindingPath = "nextScreen",
                formatListItemCallback      = StringFormatCallback,
                formatSelectedValueCallback = StringFormatCallback
            };

            popup.RegisterValueChangedCallback(evt => {
                nextScreenProperty.objectReferenceValue = evt.newValue;
                nextScreenProperty.serializedObject.ApplyModifiedProperties();
            });

            var backToggle = new Toggle("Back to previous")
            {
                bindingPath = "back"
            };

            backToggle.RegisterValueChangedCallback(evt => { popup.SetEnabled(!evt.newValue); });

            popup.SetEnabled(!serializedObject.FindProperty("back").boolValue);

            root.Add(backToggle);
            root.Add(popup);

            return(root);
        }
Beispiel #22
0
        VisualElement CreateAlbedoContent()
        {
            var root = new VisualElement()
            {
                name = "Albedo and Metals"
            };

            var validateTrueMetals = new Toggle("Check Pure Metals");

            validateTrueMetals.SetValueWithoutNotify(sceneView.validateTrueMetals);
            validateTrueMetals.RegisterValueChangedCallback(ValidateTrueMetalsChanged);
            validateTrueMetals.tooltip = "Check if albedo is black for materials with an average specular color above 0.45";
            root.Add(validateTrueMetals);

            var albedoSpecificContent = new VisualElement()
            {
                name = "Albedo"
            };

            if (PlayerSettings.colorSpace == ColorSpace.Gamma)
            {
                albedoSpecificContent.Add(new HelpBox("Albedo Validation doesn't work when Color Space is set to gamma space",
                                                      HelpBoxMessageType.Warning));
            }

            m_SelectedAlbedoSwatch        = m_AlbedoSwatchInfos[0];
            m_SelectedAlbedoPopup         = new PopupField <AlbedoSwatchInfo>("Luminance Validation", m_AlbedoSwatchInfos, m_SelectedAlbedoSwatch);
            m_SelectedAlbedoPopup.tooltip = "Select default luminance validation or validate against a configured albedo swatch";
            m_SelectedAlbedoPopup.formatListItemCallback      = swatch => swatch.name;
            m_SelectedAlbedoPopup.formatSelectedValueCallback = swatch => swatch.name;
            m_SelectedAlbedoPopup.RegisterValueChangedCallback(SetSelectedAlbedoSwatch);

            albedoSpecificContent.Add(m_SelectedAlbedoPopup);
            albedoSpecificContent.Add(m_AlbedoContent = CreateColorSwatch("magenta", Color.magenta));

            var hue = EditorGUIUtility.TrTextContent("Hue Tolerance:", "Check that the hue of the albedo value of a " +
                                                     "material is within the tolerance of the hue of the albedo swatch being validated against");
            var sat = EditorGUIUtility.TrTextContent("Saturation Tolerance:", "Check that the saturation of the albedo " +
                                                     "value of a material is within the tolerance of the saturation of the albedo swatch being validated against");

            m_AlbedoHueTolerance = CreateSliderWithField(hue, m_AlbedoSwatchHueTolerance, k_AlbedoHueToleranceMin, k_AlbedoHueToleranceMax, SetAlbedoHueTolerance);
            albedoSpecificContent.Add(m_AlbedoHueTolerance);

            m_AlbedoSaturationTolerance = CreateSliderWithField(sat, m_AlbedoSwatchSaturationTolerance, k_AlbedoHueToleranceMin, k_AlbedoHueToleranceMax, SetSaturationTolerance);
            albedoSpecificContent.Add(m_AlbedoSaturationTolerance);

            root.Add(albedoSpecificContent);
            root.Add(CreateColorLegend());

            return(root);
        }
Beispiel #23
0
        async Task RefreshVenueSelector(GroupID groupIdToSelect = null, VenueID venueIdToSelect = null)
        {
            selector.Clear();
            selector.Add(new IMGUIContainer(() => EditorGUILayout.HelpBox("会場情報を取得しています...", MessageType.None)));

            VisualElement venuePicker = null;

            void RecreateVenuePicker(GroupID groupId)
            {
                if (venuePicker != null)
                {
                    selector.Remove(venuePicker);
                }

                venuePicker = CreateVenuePicker(groupId, allVenues[groupId], venueIdToSelect);
                selector.Add(venuePicker);
            }

            try
            {
                var groups = await APIServiceClient.GetGroups.Call(Empty.Value, userInfo.VerifiedToken, 3);

                foreach (var group in groups.List)
                {
                    allVenues[group.Id] = await APIServiceClient.GetGroupVenues.Call(group.Id, userInfo.VerifiedToken, 3);
                }

                selector.Clear();
                if (groups.List.Count == 0)
                {
                    selector.Add(new IMGUIContainer(() => EditorGUILayout.HelpBox("clusterにてチーム登録をお願いいたします", MessageType.Warning)));
                }
                else
                {
                    var teamMenu = new PopupField <Group>("所属チーム", groups.List, 0, group => group.Name, group => group.Name);
                    teamMenu.RegisterValueChangedCallback(ev => RecreateVenuePicker(ev.newValue.Id));
                    selector.Add(teamMenu);

                    var groupToSelect = groups.List.Find(group => group.Id == groupIdToSelect) ?? groups.List[0];
                    teamMenu.SetValueWithoutNotify(groupToSelect);

                    RecreateVenuePicker(groupToSelect.Id);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                selector.Clear();
                selector.Add(new IMGUIContainer(() => EditorGUILayout.HelpBox($"会場情報の取得に失敗しました {e.Message}", MessageType.Error)));
            }
        }
Beispiel #24
0
        private VisualElement BuildSpeakerField(SerializedProperty property, Action <SpeakerInfoAsset> updateFaceField)
        {
            if (property.propertyType != SerializedPropertyType.ObjectReference)
            {
                throw new ArgumentException();
            }

            var currentObject = property.objectReferenceValue;

            var assetGuids = AssetDatabase.FindAssets("t:SpeakerInfoAsset");

            var assets = assetGuids.Select(guid =>
                                           AssetDatabase.LoadAssetAtPath <SpeakerInfoAsset>(AssetDatabase.GUIDToAssetPath(guid))).ToList();//Resources.FindObjectsOfTypeAll<SpeakerInfoAsset>().ToList();

            assets.Insert(0, null);


            int index = -1;

            if (currentObject is SpeakerInfoAsset currentSpeakerInfoAsset)
            {
                index = assets.IndexOf(currentSpeakerInfoAsset);
            }
            else if (currentObject == null)
            {
                index = 0;
            }

            if (index < 0)
            {
                return(new ObjectField("話者")
                {
                    bindingPath = property.propertyPath
                });
            }

            Func <SpeakerInfoAsset, string> formatter = asset => asset ? asset.SpeakerInfo.Name : "(None)";
            var menu = new PopupField <SpeakerInfoAsset>(assets, index, formatter, formatter);

            menu.label = "話者";

            menu.RegisterValueChangedCallback(evt =>
            {
                property.objectReferenceValue = evt.newValue;
                property.serializedObject.ApplyModifiedProperties();
                updateFaceField.Invoke(evt.newValue);
            });


            return(menu);
        }
        public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            var root = new VisualElement()
            {
                name = "",
            };

            root.style.flexDirection = new StyleEnum <FlexDirection>(FlexDirection.Row);

            var textTemplateEngine = GetTargetTextTemplateEngine(property);

            Assert.IsNotNull(textTemplateEngine);

            var keywordList = new List <string> {
                ""
            };

            keywordList.AddRange(textTemplateEngine.Keywords.Select(k => k.key));
            var keywordPopup = new PopupField <string>(keywordList, 0)
            {
                name        = "IgonrePairKeywordPopup",
                bindingPath = $"{property.propertyPath}.keyword",
            };

            keywordPopup.style.flexGrow = new StyleFloat(0.5f);
            keywordPopup.RegisterValueChangedCallback(e => {
                var pairValuePopup = keywordPopup.parent.Children()
                                     .First(c => c.name == VALUE_POPUP_NAME) as PopupField <string>;
                string log = "";
                foreach (var child in pairValuePopup.Children())
                {
                    log += $"{child.name}:type={child.GetType().Name} {child.childCount} {child.ElementAt(0).GetType().Name} ";
                }
                Debug.Log($"debug -- value count={pairValuePopup.childCount} log={log}");
                //e.newValue;
            });
            root.Add(keywordPopup);

            var valueList = new List <string> {
                "", "hoge", "foo", "bar"
            };
            var valuePopup = new PopupField <string>(valueList, 0)
            {
                name        = VALUE_POPUP_NAME,
                bindingPath = $"{property.propertyPath}.value",
            };

            valuePopup.style.flexGrow = new StyleFloat(0.5f);
            root.Add(valuePopup);
            return(root);
        }