/// <summary> /// 读取打包资源配置信息. /// </summary> /// <returns>打包资源配置信息.</returns> /// <param name="iDirPath">Asset存放目录文件(不指定:当前选定对象所在目录).</param> public static T ReadSetting <T>(string iDirPath = null) where T : UnityEngine.ScriptableObject { T objRet = default(T); string path = null; try { path = GetAssetFilePath <T>(iDirPath); if (true == string.IsNullOrEmpty(path)) { UtilsLog.Error("UtilityAsset", "GetAssetFilePath():Failed!!!(Dir:{0})", true == string.IsNullOrEmpty(iDirPath) ? "null" : iDirPath); return(objRet); } UtilsLog.Info("UtilityAsset", "ReadSetting:{0}", path); objRet = UtilsAsset.LoadAssetFile <T>(path); SetAssetDirty(objRet); } catch (System.IO.DirectoryNotFoundException exp) { UtilsLog.Fatal("UtilityAsset", "ReadSetting()::Failed!!! DetailInfo ClassName:{0} \n AssetFile:{1} \n Error:{2}", typeof(T).ToString(), (path == null) ? "null" : path, exp.Message); } if (default(T) == objRet) { objRet = UtilsAsset.CreateAsset <T> (iDirPath); AssetsRefresh(); SetAssetDirty(objRet); } return(objRet); }
/// <summary> /// 从JSON文件,导入打包配置信息. /// </summary> /// <returns><c>true</c>, 导入成功, <c>false</c> 导入失败.</returns> /// <param name="iImportDir">导入路径.</param> /// <param name="iForceClear">强制清空.</param> public virtual bool ImportFromJsonFile(string iImportDir, bool iForceClear = true) { string importDir = iImportDir; if (true == string.IsNullOrEmpty(iImportDir)) { importDir = this.GetImportPath(); } else { this.ImportJsonPath = iImportDir; } bool fileExistFlg = false; T2 jsonData = UtilsAsset.ImportDataByDir <T2> (out fileExistFlg, importDir); if (jsonData != null) { this.ApplyData(jsonData, iForceClear); return(true); } // 文件不存在则,视为导入成功 if (false == fileExistFlg) { this.Init(); return(true); } return(false); }
/// <summary> /// 用用数据. /// </summary> /// <param name="iData">数据.</param> /// <param name="iForceClear">强制清空标志位.</param> protected override void ApplyData(BuildInfoData iData, bool iForceClear) { if (null == iData) { return; } // 清空 if (true == iForceClear) { this.Clear(); } // 默认数据 this.Data.Default.BuildName = iData.Default.BuildName; this.Data.Default.BuildID = iData.Default.BuildID; this.Data.Default.BuildVersion = iData.Default.BuildVersion; this.Data.Default.BuildShortVersion = iData.Default.BuildShortVersion; this.Data.Default.BuildVersionCode = iData.Default.BuildVersionCode; this.Data.Default.CenterVersion = iData.Default.CenterVersion; this.Data.Default.PlatformType = iData.Default.PlatformType; this.Data.Default.LogLevel = iData.Default.LogLevel; // 选项数据 this.Data.Options.OptionsSettings = iData.Options.OptionsSettings; UtilsAsset.SetAssetDirty(this); }
static void Clear() { BuildInfo _info = BuildInfo.GetInstance(); if (null != _info) { _info.Clear(); } UtilsAsset.AssetsRefresh(); }
/// <summary> /// 创建设定文件(在当前目录). /// </summary> protected static T1 CreateAssetAtCurDir() { string curDir = GetCurDir(); if (Directory.Exists(curDir) == false) { return(null); } return(UtilsAsset.CreateAsset <T1> (curDir)); }
static void Export() { AutoRefreshImagesSetting setting = AutoRefreshImagesSetting.GetInstance(); if (setting != null) { setting.ExportToJsonFile(); } UtilsAsset.AssetsRefresh(); }
static void Clear() { AutoRefreshImagesSetting setting = AutoRefreshImagesSetting.GetInstance(); if (setting != null) { setting.Clear(); } UtilsAsset.AssetsRefresh(); }
static void Export() { BuildInfo _info = BuildInfo.GetInstance(); if (null != _info) { _info.ExportToJsonFile(); } UtilsAsset.AssetsRefresh(); }
/// <summary> /// 清空. /// </summary> /// <param name="iIsFileDelete">删除数据文件标志位.</param> /// <param name="iDirPath">Asset存放目录文件(不指定:当前选定对象所在目录).</param> public virtual void Clear(bool iIsFileDelete = false, string iDirPath = null) { // 清空数据 this.ClearData(); // 删除数据文件 if (true == iIsFileDelete) { UtilsAsset.DeleteFile <T2> (iDirPath); } UtilsAsset.SetAssetDirty(this); }
/// <summary> /// 清空. /// </summary> /// <param name="iIsFileDelete">删除数据文件标志位.</param> public virtual void Clear(bool iIsFileDelete = false) { // 清空数据 this.ClearData(); // 删除数据文件 if (true == iIsFileDelete) { UtilsAsset.DeleteFile <BuildInfoData> (); } UtilsAsset.SetAssetDirty(this); }
/// <summary> /// 初始化标题信息. /// </summary> /// <param name="iTarget">目标信息.</param> protected virtual void InitTitleInfo(T1 iTarget) { if (true == string.IsNullOrEmpty(this._importDir)) { this._importDir = UtilsAsset.CheckMatchPath(this._assetSetting.GetImportPath()); } EditorGUILayout.LabelField("Import Dir", this._importDir); if (true == string.IsNullOrEmpty(this._exportDir)) { this._exportDir = UtilsAsset.CheckMatchPath(this._assetSetting.GetExportPath()); } EditorGUILayout.LabelField("Export Dir", this._exportDir); }
/// <summary> /// 导出成JSON文件. /// </summary> /// <returns>导出文件(Json格式).</returns> /// <param name="iExportDir">导出路径.</param> public virtual string ExportToJsonFile(string iExportDir) { string exportDir = iExportDir; if (true == string.IsNullOrEmpty(exportDir)) { exportDir = this.GetExportPath(); } else { this.ExportJsonPath = iExportDir; } return(UtilsAsset.ExportData <T2> (this.Data, exportDir)); }
/// <summary> /// 导出成JSON文件. /// </summary> /// <returns>导出文件(Json格式).</returns> /// <param name="iExportDir">导出路径.</param> public virtual string ExportToJsonFile(string iExportDir) { string exportDir = iExportDir; if (true == string.IsNullOrEmpty(exportDir)) { exportDir = this.JsonPath; } if (false == UtilsAsset.CheckAndCreateDirByFullPath(this.JsonPath)) { UtilsLog.Error(this.ClassName, "ExportToJsonFile -> CheckAndCreateDirByFullPath Failed!!! \n (Path:{0})", this.JsonPath); return(null); } return(UtilsAsset.ExportData <T1> (this.Data, exportDir)); }
/// <summary> /// 用用数据. /// </summary> /// <param name="iData">数据.</param> /// <param name="iForceClear">强制清空标志位.</param> protected override void ApplyData(AutoRefreshImagesSettingData iData, bool iForceClear) { if (null == iData) { return; } // 清空 if (true == iForceClear) { this.Clear(); } this.Data.Settings = iData.Settings; UtilsAsset.SetAssetDirty(this); }
/// <summary> /// 取得实例. /// </summary> /// <returns>实例.</returns> /// <param name="iPath">读取路径.</param> public static T1 GetInstance(string iPath = null) { if (_instance == null) { _instance = UtilsAsset.ReadSetting <T1>(iPath); string _name = typeof(T1).Name; if ((null != _instance) && (true == _instance.Init())) { UtilsLog.Info(_name, "GetInstance Successed!!!"); } else { UtilsLog.Error(_name, "GetInstance Failed!!!"); return(null); } } return(_instance); }
/// <summary> /// 从JSON文件,导入打包配置信息. /// </summary> /// <returns><c>true</c>, 导入成功, <c>false</c> 导入失败.</returns> /// <param name="iImportDir">导入路径.</param> /// <param name="iForceClear">强制清空.</param> public virtual bool ImportFromJsonFile(string iImportDir, bool iForceClear = true) { string importDir = iImportDir; if (true == string.IsNullOrEmpty(iImportDir)) { importDir = this.JsonPath; } bool fileExistFlg = false; T1 jsonData = UtilsAsset.ImportDataByDir <T1> (out fileExistFlg, importDir); if (jsonData != null) { this.ApplyImportData(jsonData, iForceClear); return(true); } return(false); }
/// <summary> /// 取得实例. /// </summary> /// <returns>实例.</returns> /// <param name="iPath">读取路径.</param> public static T1 GetInstance(string iPath = null) { if (_instance == null) { _instance = UtilsAsset.ReadSetting <T1>(iPath); string _name = typeof(T1).Name; if ((null != _instance) && (true == _instance.Init())) { UtilsLog.Info(_name, "GetInstance()::Successed!!!(Path:{0})", (true == string.IsNullOrEmpty(iPath)) ? "null" : iPath); } else { UtilsLog.Error(_name, "GetInstance()::Failed!!!(Path:{0})", (true == string.IsNullOrEmpty(iPath)) ? "null" : iPath); return(null); } } return(_instance); }
/// <summary> /// 用用数据. /// </summary> /// <param name="iData">数据.</param> /// <param name="iForceClear">强制清空标志位.</param> protected override void ApplyData(BuildInfoData iData, bool iForceClear) { if (null == iData) { return; } // 清空 if (true == iForceClear) { this.Clear(); } this.Data.BuildName = iData.BuildName; this.Data.BuildID = iData.BuildID; this.Data.BuildVersion = iData.BuildVersion; this.Data.BuildShortVersion = iData.BuildShortVersion; this.Data.BuildVersionCode = iData.BuildVersionCode; this.Data.CenterVersion = iData.CenterVersion; UtilsAsset.SetAssetDirty(this); }
/// <summary> /// 创建设定文件(在当前目录). /// </summary> protected static T1 CreateAsset() { return(UtilsAsset.CreateAsset <T1> ()); }
static AutoRefreshImagesSetting Create() { return(UtilsAsset.CreateAsset <AutoRefreshImagesSetting> ()); }