public static void TransferRulePropertiesToSelector(this StyleSheet toStyleSheet, StyleComplexSelector toSelector, StyleSheet fromStyleSheet, StyleRule fromRule) { foreach (var property in fromRule.properties) { var newProperty = toStyleSheet.AddProperty(toSelector, property.name); foreach (var value in property.values) { switch (value.valueType) { case StyleValueType.Float: toStyleSheet.AddValue(newProperty, fromStyleSheet.GetFloat(value)); break; #if UNITY_2019_3_OR_NEWER case StyleValueType.Dimension: toStyleSheet.AddValue(newProperty, fromStyleSheet.GetDimension(value)); break; #endif case StyleValueType.Enum: toStyleSheet.AddValueAsEnum(newProperty, fromStyleSheet.GetEnum(value)); break; case StyleValueType.String: toStyleSheet.AddValue(newProperty, fromStyleSheet.GetString(value)); break; case StyleValueType.Color: toStyleSheet.AddValue(newProperty, fromStyleSheet.GetColor(value)); break; case StyleValueType.AssetReference: toStyleSheet.AddValue(newProperty, fromStyleSheet.GetAsset(value)); break; case StyleValueType.ResourcePath: toStyleSheet.AddValue(newProperty, fromStyleSheet.GetAsset(value)); break; #if UNITY_2019_3_OR_NEWER // UNITY_BUILDER_VARIABLE_SUPPORT case StyleValueType.Variable: toStyleSheet.AddVariable(newProperty, fromStyleSheet.GetString(value)); break; #endif } } } foreach (var property in fromRule.properties) { fromStyleSheet.RemoveProperty(fromRule, property); } }
StyleValueHandle[] AddVariableToStyleSheet(string variableName) { return(styleSheet.AddVariable(styleProperty, variableName)); }