static T CheckAccess <T>(T[] list, StyleValueType type, StyleValueHandle handle) { T value = default(T); if (handle.valueType != type) { Debug.LogErrorFormat("Trying to read value of type {0} while reading a value of type {1}", type, handle.valueType); } else if (list == null || handle.valueIndex < 0 || handle.valueIndex >= list.Length) { Debug.LogError("Accessing invalid property"); } else { value = list[handle.valueIndex]; } return(value); }
private static bool TryCheckAccess <T>(T[] list, StyleValueType type, StyleValueHandle handle, out T value) { bool result = false; value = default(T); bool flag = handle.valueType == type && handle.valueIndex >= 0 && handle.valueIndex < list.Length; if (flag) { value = list[handle.valueIndex]; result = true; } else { Debug.LogErrorFormat("Trying to read value of type {0} while reading a value of type {1}", new object[] { type, handle.valueType }); } return(result); }
internal StyleValueKeyword ReadKeyword(StyleValueHandle handle) { return((StyleValueKeyword)handle.valueIndex); }
internal StyleValueFunction ReadFunction(StyleValueHandle handle) { return((StyleValueFunction)handle.valueIndex); }
internal string ReadFunctionName(StyleValueHandle handle) { return(CheckAccess(strings, StyleValueType.Function, handle)); }
internal bool TryReadResourcePath(StyleValueHandle handle, out string value) { return(StyleSheet.TryCheckAccess <string>(this.strings, StyleValueType.ResourcePath, handle, out value)); }
internal string ReadMissingAssetReferenceUrl(StyleValueHandle handle) { return(StyleSheet.CheckAccess <string>(this.strings, StyleValueType.MissingAssetReference, handle)); }
internal string ReadEnum(StyleValueHandle handle) { return(StyleSheet.CheckAccess <string>(this.strings, StyleValueType.Enum, handle)); }
internal bool TryReadVariable(StyleValueHandle handle, out string value) { return(StyleSheet.TryCheckAccess <string>(this.strings, StyleValueType.Variable, handle, out value)); }
internal string ReadVariable(StyleValueHandle handle) { return(CheckAccess(strings, StyleValueType.Variable, handle)); }
internal bool TryReadVariable(StyleValueHandle handle, out string value) { return(TryCheckAccess(strings, StyleValueType.Variable, handle, out value)); }
internal string ReadEnum(StyleValueHandle handle) { return(CheckAccess(strings, StyleValueType.Enum, handle)); }
internal bool TryReadEnum(StyleValueHandle handle, out string value) { return(TryCheckAccess(strings, StyleValueType.Enum, handle, out value)); }
internal string ReadString(StyleValueHandle handle) { return(CheckAccess(strings, StyleValueType.String, handle)); }
internal bool TryReadColor(StyleValueHandle handle, out Color value) { return(TryCheckAccess(colors, StyleValueType.Color, handle, out value)); }
internal Color ReadColor(StyleValueHandle handle) { return(CheckAccess(colors, StyleValueType.Color, handle)); }
internal Color ReadColor(StyleValueHandle handle) { return(StyleSheet.CheckAccess <Color>(this.colors, StyleValueType.Color, handle)); }
internal string ReadResourcePath(StyleValueHandle handle) { return(CheckAccess(strings, StyleValueType.ResourcePath, handle)); }
internal bool TryReadColor(StyleValueHandle handle, out Color value) { return(StyleSheet.TryCheckAccess <Color>(this.colors, StyleValueType.Color, handle, out value)); }
internal bool TryReadResourcePath(StyleValueHandle handle, out string value) { return(TryCheckAccess(strings, StyleValueType.ResourcePath, handle, out value)); }
internal string ReadVariable(StyleValueHandle handle) { return(StyleSheet.CheckAccess <string>(this.strings, StyleValueType.Variable, handle)); }
internal Object ReadAssetReference(StyleValueHandle handle) { return(CheckAccess(assets, StyleValueType.AssetReference, handle)); }
internal string ReadResourcePath(StyleValueHandle handle) { return(StyleSheet.CheckAccess <string>(this.strings, StyleValueType.ResourcePath, handle)); }
internal bool TryReadAssetReference(StyleValueHandle handle, out Object value) { return(TryCheckAccess(assets, StyleValueType.AssetReference, handle, out value)); }
internal UnityEngine.Object ReadAssetReference(StyleValueHandle handle) { return(StyleSheet.CheckAccess <UnityEngine.Object>(this.assets, StyleValueType.AssetReference, handle)); }
internal string ReadMissingAssetReferenceUrl(StyleValueHandle handle) { return(CheckAccess(strings, StyleValueType.MissingAssetReference, handle)); }
internal bool TryReadAssetReference(StyleValueHandle handle, out UnityEngine.Object value) { return(StyleSheet.TryCheckAccess <UnityEngine.Object>(this.assets, StyleValueType.AssetReference, handle, out value)); }
private void SetupReferences() { bool flag = this.complexSelectors == null || this.rules == null; if (!flag) { StyleRule[] rules = this.rules; for (int i = 0; i < rules.Length; i++) { StyleRule styleRule = rules[i]; StyleProperty[] properties = styleRule.properties; for (int j = 0; j < properties.Length; j++) { StyleProperty styleProperty = properties[j]; bool flag2 = StyleSheet.CustomStartsWith(styleProperty.name, StyleSheet.kCustomPropertyMarker); if (flag2) { styleRule.customPropertiesCount++; styleProperty.isCustomProperty = true; } StyleValueHandle[] values = styleProperty.values; for (int k = 0; k < values.Length; k++) { StyleValueHandle handle = values[k]; bool flag3 = handle.IsVarFunction(); if (flag3) { styleProperty.requireVariableResolve = true; break; } } } } int l = 0; int num = this.complexSelectors.Length; while (l < num) { this.complexSelectors[l].CachePseudoStateMasks(); l++; } this.orderedClassSelectors = new Dictionary <string, StyleComplexSelector>(StringComparer.Ordinal); this.orderedNameSelectors = new Dictionary <string, StyleComplexSelector>(StringComparer.Ordinal); this.orderedTypeSelectors = new Dictionary <string, StyleComplexSelector>(StringComparer.Ordinal); int m = 0; while (m < this.complexSelectors.Length) { StyleComplexSelector styleComplexSelector = this.complexSelectors[m]; bool flag4 = styleComplexSelector.ruleIndex < this.rules.Length; if (flag4) { styleComplexSelector.rule = this.rules[styleComplexSelector.ruleIndex]; } styleComplexSelector.orderInStyleSheet = m; StyleSelector styleSelector = styleComplexSelector.selectors[styleComplexSelector.selectors.Length - 1]; StyleSelectorPart styleSelectorPart = styleSelector.parts[0]; string key = styleSelectorPart.value; Dictionary <string, StyleComplexSelector> dictionary = null; switch (styleSelectorPart.type) { case StyleSelectorType.Wildcard: case StyleSelectorType.Type: key = (styleSelectorPart.value ?? "*"); dictionary = this.orderedTypeSelectors; break; case StyleSelectorType.Class: dictionary = this.orderedClassSelectors; break; case StyleSelectorType.PseudoClass: key = "*"; dictionary = this.orderedTypeSelectors; break; case StyleSelectorType.RecursivePseudoClass: goto IL_22B; case StyleSelectorType.ID: dictionary = this.orderedNameSelectors; break; default: goto IL_22B; } IL_249: bool flag5 = dictionary != null; if (flag5) { StyleComplexSelector nextInTable; bool flag6 = dictionary.TryGetValue(key, out nextInTable); if (flag6) { styleComplexSelector.nextInTable = nextInTable; } dictionary[key] = styleComplexSelector; } m++; continue; IL_22B: Debug.LogError(string.Format("Invalid first part type {0}", styleSelectorPart.type)); goto IL_249; } } }
internal ScalableImage ReadScalableImage(StyleValueHandle handle) { return(StyleSheet.CheckAccess <ScalableImage>(this.scalableImages, StyleValueType.ScalableImage, handle)); }
internal ScalableImage ReadScalableImage(StyleValueHandle handle) { return(CheckAccess(scalableImages, StyleValueType.ScalableImage, handle)); }