internal bool TryGetValueFromBagAsString(IUxmlAttributes bag, CreationContext cc, out string value) { if (name == null) { if (obsoleteNames == null || obsoleteNames.Length == 0) { Debug.LogError("Attribute description has no name."); value = null; return(false); } for (var i = 0; i < obsoleteNames.Length; i++) { if (bag.TryGetAttributeValue(obsoleteNames[i], out value)) { if (cc.visualTreeAsset != null) { } return(true); } } value = null; return(false); } if (!bag.TryGetAttributeValue(name, out value)) { if (obsoleteNames != null) { for (var i = 0; i < obsoleteNames.Length; i++) { if (bag.TryGetAttributeValue(obsoleteNames[i], out value)) { if (cc.visualTreeAsset != null) { } return(true); } } } value = null; return(false); } return(true); }
public override UnityEngine.UIElements.VisualElement Create(IUxmlAttributes bag, CreationContext cc) #endif { var foundSrc = bag.TryGetAttributeValue("src", out var src); if (foundSrc) { if (src.StartsWith("Assets") || src.StartsWith("Packages") || src.StartsWith("/Assets") || src.StartsWith("/Packages")) { #if UNITY_2018 cc.target.AddStyleSheetPath(src.TrimStart('/')); #else cc.target.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(src.TrimStart('/'))); #endif } else { var vta = cc.visualTreeAsset; var vtaPath = AssetDatabase.GetAssetPath(vta); var vtaDirector = Path.GetDirectoryName(vtaPath); string sheetPath = Path.GetFullPath(Path.Combine(vtaDirector, src)).Replace(Directory.GetCurrentDirectory(), "").TrimStart('\\', '/'); #if UNITY_2018 cc.target.AddStyleSheetPath(sheetPath); #else cc.target.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(sheetPath)); #endif } } return(fakeStyleElement); }
internal bool TryGetValueFromBagAsString(IUxmlAttributes bag, CreationContext cc, out string value) { // Regardless of whether the attribute is overwridden or not, we want to error here // if there is no valid name. if (name == null && (m_ObsoleteNames == null || m_ObsoleteNames.Length == 0)) { Debug.LogError("Attribute description has no name."); value = null; return(false); } string elementName; bag.TryGetAttributeValue("name", out elementName); if (!string.IsNullOrEmpty(elementName) && cc.attributeOverrides != null) { for (var i = 0; i < cc.attributeOverrides.Count; ++i) { if (cc.attributeOverrides[i].m_ElementName != elementName) { continue; } if (cc.attributeOverrides[i].m_AttributeName != name) { if (m_ObsoleteNames != null) { bool matchedObsoleteName = false; for (var j = 0; j < m_ObsoleteNames.Length; j++) { if (cc.attributeOverrides[i].m_AttributeName == m_ObsoleteNames[j]) { matchedObsoleteName = true; break; } } if (!matchedObsoleteName) { continue; } } else { continue; } } value = cc.attributeOverrides[i].m_Value; return(true); } } if (name == null) { // Check for: // (m_ObsoleteNames == null || m_ObsoleteNames.Length == 0) // moved at the top of method so we can assume we have obsolete names here. for (var i = 0; i < m_ObsoleteNames.Length; i++) { if (bag.TryGetAttributeValue(m_ObsoleteNames[i], out value)) { if (cc.visualTreeAsset != null) { } return(true); } } value = null; return(false); } if (!bag.TryGetAttributeValue(name, out value)) { if (m_ObsoleteNames != null) { for (var i = 0; i < m_ObsoleteNames.Length; i++) { if (bag.TryGetAttributeValue(m_ObsoleteNames[i], out value)) { if (cc.visualTreeAsset != null) { } return(true); } } } value = null; return(false); } return(true); }
internal bool TryGetValueFromBagAsString(IUxmlAttributes bag, CreationContext cc, out string value) { bool flag = this.name == null && (this.m_ObsoleteNames == null || this.m_ObsoleteNames.Length == 0); bool result; if (flag) { Debug.LogError("Attribute description has no name."); value = null; result = false; } else { string text; bag.TryGetAttributeValue("name", out text); bool flag2 = !string.IsNullOrEmpty(text) && cc.attributeOverrides != null; if (flag2) { for (int i = 0; i < cc.attributeOverrides.Count; i++) { bool flag3 = cc.attributeOverrides[i].m_ElementName != text; if (!flag3) { bool flag4 = cc.attributeOverrides[i].m_AttributeName != this.name; if (flag4) { bool flag5 = this.m_ObsoleteNames != null; if (!flag5) { goto IL_147; } bool flag6 = false; for (int j = 0; j < this.m_ObsoleteNames.Length; j++) { bool flag7 = cc.attributeOverrides[i].m_AttributeName == this.m_ObsoleteNames[j]; if (flag7) { flag6 = true; break; } } bool flag8 = !flag6; if (flag8) { goto IL_147; } } value = cc.attributeOverrides[i].m_Value; result = true; return(result); } IL_147 :; } } bool flag9 = this.name == null; if (flag9) { for (int k = 0; k < this.m_ObsoleteNames.Length; k++) { bool flag10 = bag.TryGetAttributeValue(this.m_ObsoleteNames[k], out value); if (flag10) { bool flag11 = cc.visualTreeAsset != null; if (flag11) { } result = true; return(result); } } value = null; result = false; } else { bool flag12 = !bag.TryGetAttributeValue(this.name, out value); if (flag12) { bool flag13 = this.m_ObsoleteNames != null; if (flag13) { for (int l = 0; l < this.m_ObsoleteNames.Length; l++) { bool flag14 = bag.TryGetAttributeValue(this.m_ObsoleteNames[l], out value); if (flag14) { bool flag15 = cc.visualTreeAsset != null; if (flag15) { } result = true; return(result); } } } value = null; result = false; } else { result = true; } } } return(result); }