Esempio n. 1
0
        private void DrawFields(ScorerData scData, List <string> keys)
        {
            CurveField          curveField = new CurveField("uFunction");
            int                 index      = keys.IndexOf(scData.key);
            PopupField <string> popupField = new PopupField <string>("key", keys, index);

            /*UnityExtensions.DebugLogEnumerable(popupField.GetClasses());
            *  UnityExtensions.DebugLogEnumerable(curveField.GetClasses());*/
            curveField.BindProperty(serData.FindPropertyRelative("uFunction"));
            popupField.BindProperty(serData.FindPropertyRelative("key"));
            contentContainer.Add(curveField);
            contentContainer.Add(popupField);
        }
Esempio n. 2
0
        public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            var qualifiedName = property.FindPropertyRelative("assemblyQualifiedName");
            var types         = GetTypes(property);

            types.Insert(0, null);
            var type  = string.IsNullOrEmpty(qualifiedName.stringValue) ? null : Type.GetType(qualifiedName.stringValue);
            var popup = new PopupField <SerializableType>(property.displayName, types, null, t => t.Value?.FullName ?? MISSING_TEXT)
            {
                value = new SerializableType(type)
            };

            popup.BindProperty(property);
            return(popup);
        }
Esempio n. 3
0
        public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            var           settings    = ProjectUtility.GetProjectSettings <ActionGraphGlobalSettings>();
            var           definitions = ActionDefinitionAsset.LoadAll().ToArray();
            List <string> guids       = definitions.Select(a => a.id.guid).ToList();

            guids.Insert(0, string.Empty);
            var popup = new PopupField <string>(property.displayName, guids, property.FindPropertyRelative("guid").stringValue, (choice) => FormatCell(definitions, choice)
                                                , (choice) => FormatCell(definitions, choice)
                                                );

            popup.SetEnabled(settings != null);
            popup.BindProperty(property.FindPropertyRelative("guid"));
            return(popup);
        }
Esempio n. 4
0
        private void DrawFields(QualifierData qData, List <string> actions)
        {
            EnumField qualTypeField = new EnumField("type", QualiScorer.QualiType.SumOfChildren);

            qualTypeField.BindProperty(serData.FindPropertyRelative("qualiType"));
            LimitedFloatField thresholdField = new LimitedFloatField("threshold", 0, 1);

            thresholdField.BindProperty(serData.FindPropertyRelative("threshold"));
            int actionIndex = actions.IndexOf(qData.actionName);
            PopupField <string> actionNameField = new PopupField <string>("action", actions, actionIndex);

            actionNameField.BindProperty(serData.FindPropertyRelative("actionName"));

            contentContainer.Add(qualTypeField);
            contentContainer.Add(thresholdField);
            contentContainer.Add(actionNameField);
        }
Esempio n. 5
0
        protected override void DrawSelection(Box cardInfo, Components.CharacterSO character)
        {
            EditorGUI.BeginChangeCheck();

            serializedObject.UpdateIfRequiredOrScript();
            SerializedProperty iterator = serializedObject.GetIterator();

            for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false)
            {
                if (iterator.name != "id")
                {
                    PropertyField prop = new PropertyField(iterator);
                    prop.Bind(serializedObject);
                    cardInfo.Add(prop);
                }
                else
                {
                    Debug.Log(iterator.propertyPath);
                    _choiceIndex = Array.FindIndex(m_PopulatedList.Keys.ToArray(), idx => idx == character.ID);

                    PopupField <uint> popupField = new PopupField <uint>("ID", m_PopulatedList.Keys.ToList(), _choiceIndex)
                    {
                        bindingPath                 = "id",
                        formatListItemCallback      = i => m_PopulatedList[i],
                        formatSelectedValueCallback = i => m_PopulatedList[i]
                    };

                    popupField.RegisterValueChangedCallback(evt =>
                    {
                        if (evt.newValue >= 0 && ItemListView.Selected != null)
                        {
                            if (ItemListView.Selected.ID != evt.newValue)
                            {
                                // TODO split these two arrays
                                // Update the selected choice in the underlying object
                                character.ID = evt.newValue;

                                OnChanged();

                                serializedObject.Update();
                                serializedObject.ApplyModifiedProperties();

                                EditorUtility.SetDirty(character);
                                SceneView.RepaintAll();
                            }
                        }
                    });

                    popupField.BindProperty(serializedObject);
                    cardInfo.Add(popupField);
                }
                using (new EditorGUI.DisabledScope("m_Script" == iterator.propertyPath))
                    EditorGUILayout.PropertyField(iterator, true);
            }
            serializedObject.ApplyModifiedProperties();
            EditorGUI.EndChangeCheck();

            /*
             * SerializedProperty serializedProperty = serializedObject.GetIterator();
             * serializedProperty.Next(true);
             *
             * while (serializedProperty.NextVisible(false))
             * {
             *      PropertyField prop = new PropertyField(serializedProperty);
             *      prop.SetEnabled(serializedProperty.name != "m_Script");
             *      prop.Bind(serializedObject);
             *      cardInfo.Add(prop);
             * }
             */
        }