public VisualElement CreateField(int index) { var key = _keysProperty.GetArrayElementAtIndex(index); var value = _valuesProperty.GetArrayElementAtIndex(index); var field = _drawer != null ? _drawer.CreatePropertyGUI(value) : value.CreateField(); field.userData = index; field.Bind(_property.serializedObject); if (field is PropertyField propertyField) { propertyField.SetLabel(key.stringValue); } else if (field is FieldContainer fieldContainer) { fieldContainer.SetLabel(key.stringValue); } if (field.GetType().InheritsGeneric(typeof(BaseField <>))) { BaseFieldExtensions.SetLabel(field, key.stringValue); } return(field); }
public static void SetLabel(this PropertyField field, string label) { // This must be scheduled because the field won't be created until the next frame after the Property Field has been set up field.schedule.Execute(() => { var baseField = field.Q(className: BaseFieldExtensions.UssClassName); BaseFieldExtensions.SetLabel(baseField, label); }).StartingIn(0); }
public override VisualElement CreatePropertyGUI(SerializedProperty property) { var element = this.CreateNextElement(property); if (element is PropertyField propertyField) { propertyField.SetLabel(null); } else if (element is FieldContainer fieldContainer) { fieldContainer.SetLabel(null); } else if (element.GetType().InheritsGeneric(typeof(BaseField <>))) { BaseFieldExtensions.SetLabel(element, null); } return(element); }
public VisualElement CreateElement(int index) { var property = _property.GetArrayElementAtIndex(index); var field = _drawer?.CreatePropertyGUI(property) ?? property.CreateField(); field.userData = index; field.Bind(_property.serializedObject); if (field is PropertyField propertyField) { propertyField.SetLabel(null); } else if (field is FieldContainer fieldContainer) { fieldContainer.SetLabel(null); } else if (field.GetType().InheritsGeneric(typeof(BaseField <>))) { BaseFieldExtensions.SetLabel(field, null); } return(field); }