/// <summary> /// 根据物理主码查询 /// </summary> /// <param name="id">id</param> /// <returns>结果</returns> public LanType SELECT_BY_ID(long id) { try { LanType rd = new LanType(); S_lantype temp = (from row in db.S_lantype where row.id == id select row).First(); rd.Id = temp.id; rd.Name = temp.name; rd.Sort = temp.sort; rd.Isused = temp.isused; return(rd); } catch { return(null); } }
/// <summary> /// 插入函数 /// </summary> /// <param name="info">Model</param> /// <returns>影响数据物理ID</returns> public long INSERT(LanType info) { try { S_lantype temp = new S_lantype(); //temp.id = info.Id; temp.name = info.Name; temp.sort = info.Sort; temp.isused = info.Isused; Table <S_lantype> table = db.GetTable <S_lantype>(); table.InsertOnSubmit(temp); db.SubmitChanges(); return(temp.id); } catch { return(-2); } }
/// <summary> /// 更新函数 /// </summary> /// <param name="info">Model</param> /// <returns>影响数据物理ID,已存在逻辑主码返回-1</returns> public long UPDATE(LanType info) { try { S_lantype temp = new S_lantype(); Table <S_lantype> table = db.GetTable <S_lantype>(); temp = (from row in db.S_lantype where row.id == info.Id select row).First(); //temp.id = info.Id; temp.name = info.Name; temp.sort = info.Sort; temp.isused = info.Isused; db.SubmitChanges(); return(temp.id); } catch { return(-2); } }
/// <summary> /// 根据使用状态查询 /// </summary> /// <param name="isused">是否使用</param> /// <returns>结果列表</returns> public IList <LanType> SELECT_BY_ISUSED(bool isused) { try { IList <LanType> result = new List <LanType>(); var temp = (from row in db.S_lantype where row.isused == isused orderby row.sort ascending select row).GetEnumerator(); while (temp.MoveNext()) { LanType element = new LanType(); element.Id = temp.Current.id; element.Name = temp.Current.name; element.Sort = temp.Current.sort; element.Isused = temp.Current.isused; result.Add(element); } return(result); } catch { return(null); } }
static void ChangeLan(LanType lantype) { #region Load Font sourceFont1; Font sourceFont2; Font targetFont1; Font targetFont2; if (lantype == LanType.CN) { sourceFont1 = AssetDatabase.LoadAssetAtPath <Font>("Assets/Font/2002.TTF"); sourceFont2 = AssetDatabase.LoadAssetAtPath <Font>("Assets/Font/RIXGOB.TTF"); targetFont1 = AssetDatabase.LoadAssetAtPath <Font>("Assets/Font/Fzzh2.TTF"); targetFont2 = AssetDatabase.LoadAssetAtPath <Font>("Assets/Font/Fzzh1.TTF"); } else { targetFont1 = AssetDatabase.LoadAssetAtPath <Font>("Assets/Font/2002.TTF"); targetFont2 = AssetDatabase.LoadAssetAtPath <Font>("Assets/Font/RIXGOB.TTF"); sourceFont1 = AssetDatabase.LoadAssetAtPath <Font>("Assets/Font/Fzzh2.TTF"); sourceFont2 = AssetDatabase.LoadAssetAtPath <Font>("Assets/Font/Fzzh1.TTF"); } if (null == sourceFont1 || null == targetFont2 || null == targetFont1 || null == targetFont2) { EditorUtility.DisplayDialog("Error", "有字体路径不对,请与洋葱联系", "OK"); return; } #endregion string[] allGuids = AssetDatabase.FindAssets("t:Prefab", new string[] { "Assets/Resources" }); int guidIndex = 0; foreach (string guid in allGuids) { EditorUtility.DisplayProgressBar("Info", "正在替换请稍后", (float)(++guidIndex) / allGuids.Length); string assetPath = AssetDatabase.GUIDToAssetPath(guid); if (assetPath.EndsWith(".prefab")) { GameObject prefab = AssetDatabase.LoadAssetAtPath <GameObject>(assetPath); if (null == prefab) { continue; } //Prefabs.Add(prefab); Text[] texts = prefab.GetComponentsInChildren <Text>(true); foreach (Text text in texts) { if (text.font == sourceFont1) { text.font = targetFont1; } if (text.font == sourceFont2) { text.font = targetFont2; } } EditorUtility.SetDirty(prefab); } } EditorUtility.ClearProgressBar(); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }