/// <summary> /// 日志输出:警告. /// </summary> /// <param name="iScript">脚本.</param> /// <param name="iFormat">格式.</param> /// <param name="iArgs">参数.</param> public void Warning(string iFormat, params object[] iArgs) { #if BUILD_DEBUG if (false == this._logOutput) { return; } UtilsLog.Warning(this.ClassName, iFormat, iArgs); #endif }
/// <summary> /// 从JSON文件,导入打包配置数据(文件必须存在). /// </summary> /// <param name="iJsonFileDir">导出Json文件目录.</param> /// <typeparam name="T">指定读取Asset文件数据类.</typeparam> public static T ImportDataByPath <T>(out bool iIsFileExist, string iJsonFilePath) where T : JsonDataBase, new() { T objRet = default(T); string jsonString = null; iIsFileExist = false; try { // 优先加载下载资源包中的信息 TextAsset _data = DataLoader.LoadData(iJsonFilePath) as TextAsset; if (null != _data) { // 读取文件 jsonString = _data.text; } else { // 若已经有文件不存在 if (File.Exists(iJsonFilePath) == false) { UtilsLog.Warning("UtilityAsset", "ImportDataByPath():File not exist!!![File:{0}]", iJsonFilePath); return(default(T)); } iIsFileExist = true; jsonString = File.ReadAllText(iJsonFilePath); } if (false == string.IsNullOrEmpty(jsonString)) { objRet = UtilsJson <T> .ConvertFromJsonString(jsonString); UtilsLog.Info("UtilityAsset", "ImportDataByPath. <- Path:{0}", iJsonFilePath); UtilsLog.Info("UtilityAsset", "ImportDataByPath. <- Data:{0}", jsonString); } } catch (System.Exception exp) { UtilsLog.Fatal("UtilityAsset", "ImportDataByPath()::Failed!!! \n ClassName:{0} \n AssetFile:{1} \n Exception:{2} \n StackTrace:{3}", typeof(T).ToString(), (iJsonFilePath == null) ? "null" : iJsonFilePath, exp.Message, exp.StackTrace); objRet = default(T); } return(objRet); }
/// <summary> /// 加载(*.asset)文件. /// * 加载优先顺序 /// 1)编辑器模式加载 /// 2)Resource下的资源 /// </summary> /// <returns>加载文件对象.</returns> /// <param name="iPath">路径.</param> /// <typeparam name="T">加载对象类型.</typeparam> public static T LoadAssetFile <T>(string iPath) where T : Object { T objRet = default(T); TextAsset textAsset = null; // 1)编辑器模式加载 #if UNITY_EDITOR objRet = AssetDatabase.LoadAssetAtPath <T>(iPath); if (objRet != default(T)) { return(objRet); } else { UtilsLog.Warning("UtilityAsset", "LoadAssetFile Failed!!! Path : {0}", iPath); } #endif // 2)Resource下的资源 // 若上述找不到,则在从资源文件夹中加载 const string _key = "Resources/"; if ((textAsset == null) && (iPath.Contains(_key) == true)) { int startIndex = iPath.IndexOf(_key); startIndex += _key.Length; string pathTmp = iPath.Substring(startIndex); int endIndex = pathTmp.LastIndexOf("."); if (-1 != endIndex) { pathTmp = pathTmp.Substring(0, endIndex); } Object objTemp = Resources.Load(pathTmp); objRet = objTemp as T; return(objRet); } return(default(T)); }
/// <summary> /// 警告日志. /// </summary> /// <param name="iScript">脚本.</param> /// <param name="iFormat">格式.</param> /// <param name="iArgs">参数.</param> public void Warning(string iFormat, params object[] iArgs) { UtilsLog.Warning(this.ClassName, iFormat, iArgs); }
/// <summary> /// 日志输出:警告. /// </summary> /// <param name="iScript">脚本.</param> /// <param name="iFormat">格式.</param> /// <param name="iArgs">参数.</param> public void Warning(string iFormat, params object[] iArgs) { #if BUILD_DEBUG UtilsLog.Warning(this.ClassName, iFormat, iArgs); #endif }