//检查路径 private AssetConfig CheckAssetPath(Type t) { int hashCode = t.GetHashCode(); AssetConfig assetCofig = null; if (!_uiAssetPath.TryGetValue(hashCode, out assetCofig)) { object[] attrs = t.GetCustomAttributes(typeof(UIViewAttribute), false); if (attrs.Length == 0) { return(null); } UIViewAttribute uIViewAttribute = attrs[0] as UIViewAttribute; if (string.IsNullOrEmpty(uIViewAttribute?.ViewPath) || string.IsNullOrEmpty(uIViewAttribute.AssetBundleName)) { return(null); } assetCofig = new AssetConfig(uIViewAttribute.AssetBundleName, uIViewAttribute.ViewPath); _uiAssetPath[hashCode] = assetCofig; } return(assetCofig); }
/// <summary> /// 根据类型获取UI的资源信息 /// </summary> /// <param name="t"></param> /// <returns></returns> private UIInstance GetUIInstance(Type t) { int hash = t.GetHashCode(); UIInstance config = null; if (!_allUIInstances.TryGetValue(hash, out config)) { object[] attrs = t.GetCustomAttributes(typeof(UIViewAttribute), false); if (attrs.Length == 0) { return(null); } UIViewAttribute uIViewAttribute = attrs[0] as UIViewAttribute; if (string.IsNullOrEmpty(uIViewAttribute?.ViewPath) || string.IsNullOrEmpty(uIViewAttribute.AssetBundleName)) { return(null); } config = new UIInstance(uIViewAttribute.AssetBundleName, uIViewAttribute.ViewPath); _allUIInstances.Add(hash, config); } return(config); }
//检查路径 private string CheckAssetPath(Type t) { int hashCode = t.GetHashCode(); string assetPath; if (!_uiAssetPath.TryGetValue(hashCode, out assetPath)) { object[] attrs = t.GetCustomAttributes(typeof(UIViewAttribute), false); if (attrs == null || attrs.Length == 0) { return(""); } UIViewAttribute uiViewAttribute = (UIViewAttribute)attrs[0]; if (string.IsNullOrEmpty(uiViewAttribute.ViewPath)) { return(""); } assetPath = uiViewAttribute.ViewPath; _uiAssetPath[hashCode] = uiViewAttribute.ViewPath; } return(assetPath); }