public void ApplyFont(StyleSheet sheet, StyleValueHandle[] handles, int specificity, ref StyleFont property) { Font font = null; if (currentStyleValue.resource.IsAllocated) { font = currentStyleValue.resource.Target as Font; } property.Apply(new StyleFont(font, currentStyleValue.keyword) { specificity = specificity }, StylePropertyApplyMode.Copy); }
public void ApplyFont(StyleSheet sheet, StyleValueHandle[] handles, int specificity, ref StyleFont property) { StyleValueHandle handle = handles[0]; Font font = null; switch (handle.valueType) { case StyleValueType.ResourcePath: { string path = sheet.ReadResourcePath(handle); if (!string.IsNullOrEmpty(path)) { font = Panel.LoadResource(path, typeof(Font)) as Font; } if (font == null) { Debug.LogWarning(string.Format("Font not found for path: {0}", path)); } } break; case StyleValueType.AssetReference: { font = sheet.ReadAssetReference(handle) as Font; if (font == null) { Debug.LogWarning("Invalid font reference"); } } break; default: Debug.LogWarning("Invalid value for font " + handle.valueType); break; } if (font != null) { var value = new StyleFont(font) { specificity = specificity }; property.Apply(value, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); } }
public void Apply(VisualElementStylesData other, StylePropertyApplyMode mode) { // Always just copy the reference to custom properties, since they can't be overriden per instance m_CustomProperties = other.m_CustomProperties; width.Apply(other.width, mode); height.Apply(other.height, mode); maxWidth.Apply(other.maxWidth, mode); maxHeight.Apply(other.maxHeight, mode); minWidth.Apply(other.minWidth, mode); minHeight.Apply(other.minHeight, mode); flexBasis.Apply(other.flexBasis, mode); flexGrow.Apply(other.flexGrow, mode); flexShrink.Apply(other.flexShrink, mode); overflow.Apply(other.overflow, mode); unityOverflowClipBox.Apply(other.unityOverflowClipBox, mode); left.Apply(other.left, mode); top.Apply(other.top, mode); right.Apply(other.right, mode); bottom.Apply(other.bottom, mode); marginLeft.Apply(other.marginLeft, mode); marginTop.Apply(other.marginTop, mode); marginRight.Apply(other.marginRight, mode); marginBottom.Apply(other.marginBottom, mode); paddingLeft.Apply(other.paddingLeft, mode); paddingTop.Apply(other.paddingTop, mode); paddingRight.Apply(other.paddingRight, mode); paddingBottom.Apply(other.paddingBottom, mode); position.Apply(other.position, mode); alignSelf.Apply(other.alignSelf, mode); unityTextAlign.Apply(other.unityTextAlign, mode); unityFontStyleAndWeight.Apply(other.unityFontStyleAndWeight, mode); fontSize.Apply(other.fontSize, mode); unityFont.Apply(other.unityFont, mode); whiteSpace.Apply(other.whiteSpace, mode); color.Apply(other.color, mode); flexDirection.Apply(other.flexDirection, mode); backgroundColor.Apply(other.backgroundColor, mode); backgroundImage.Apply(other.backgroundImage, mode); unityBackgroundScaleMode.Apply(other.unityBackgroundScaleMode, mode); unityBackgroundImageTintColor.Apply(other.unityBackgroundImageTintColor, mode); alignItems.Apply(other.alignItems, mode); alignContent.Apply(other.alignContent, mode); justifyContent.Apply(other.justifyContent, mode); flexWrap.Apply(other.flexWrap, mode); borderLeftColor.Apply(other.borderLeftColor, mode); borderTopColor.Apply(other.borderTopColor, mode); borderRightColor.Apply(other.borderRightColor, mode); borderBottomColor.Apply(other.borderBottomColor, mode); borderLeftWidth.Apply(other.borderLeftWidth, mode); borderTopWidth.Apply(other.borderTopWidth, mode); borderRightWidth.Apply(other.borderRightWidth, mode); borderBottomWidth.Apply(other.borderBottomWidth, mode); borderTopLeftRadius.Apply(other.borderTopLeftRadius, mode); borderTopRightRadius.Apply(other.borderTopRightRadius, mode); borderBottomRightRadius.Apply(other.borderBottomRightRadius, mode); borderBottomLeftRadius.Apply(other.borderBottomLeftRadius, mode); unitySliceLeft.Apply(other.unitySliceLeft, mode); unitySliceTop.Apply(other.unitySliceTop, mode); unitySliceRight.Apply(other.unitySliceRight, mode); unitySliceBottom.Apply(other.unitySliceBottom, mode); opacity.Apply(other.opacity, mode); cursor.Apply(other.cursor, mode); visibility.Apply(other.visibility, mode); display.Apply(other.display, mode); }