public static void SaveByte(byte[] pBytes, string strSavePath) { SHUtils.CreateDirectory(strSavePath); var pFile = new FileStream(strSavePath, FileMode.Create, FileAccess.Write); var pWriter = new BinaryWriter(pFile); pWriter.Write(pBytes); pWriter.Close(); pFile.Close(); // ICloud에 백업 안되게 파일에 대해 SetNoBackupFlag를 해주자!! #if UNITY_IPHONE UnityEngine.iOS.Device.SetNoBackupFlag(strSavePath); #endif UnityEngine.Debug.Log(string.Format("{0} Byte 저장", strSavePath)); }
public void SaveLoadResourceList() { string strBuff = string.Empty; SHUtils.ForToDic(m_dicRealLoadInfo, (pKey, pValue) => { strBuff += string.Format("Scene : {0}\n", pKey); SHUtils.ForToList(pValue, (pInfo) => { strBuff += string.Format("\t{0}\n", pInfo); }); }); string strSavePath = string.Format("{0}/{1}", SHPath.GetPathToAssets(), "RealTimeLoadResource.txt"); SHUtils.SaveFile(strBuff, strSavePath); System.Diagnostics.Process.Start(strSavePath); }
// 디버그 : 배포제한시간 체크 IEnumerator CheckReleaseTime() { if (true == IsEditorMode()) { yield break; } yield return(new WaitForSeconds(1.0f)); if (true == Single.Timer.IsPastTimeToLocal(m_pReleaseTime)) { SHUtils.GameQuit(); } else { StartCoroutine(CheckReleaseTime()); } }
// 인터페이스 : 타입에 해당하는 리소스 정보 리스트 얻기 public List <SHResourcesTableInfo> GetResourceInfoByType(eResourceType eType) { if (false == IsLoadTable()) { LoadJson(m_strFileName); } var pList = new List <SHResourcesTableInfo>(); SHUtils.ForToDic(m_pData, (pKey, pValue) => { if (eType == pValue.m_eResourceType) { pList.Add(pValue); } }); return(pList); }
public override Dictionary <string, SHLoadData> GetLoadList(eSceneType eType) { var dicLoadList = new Dictionary <string, SHLoadData>(); // 로컬 테이블 데이터 SHUtils.ForToDic <Type, SHBaseTable>(m_dicTables, (pKey, pValue) => { // 이미 로드된 데이터인지 체크 if (true == pValue.IsLoadTable()) { return; } dicLoadList.Add(pValue.m_strFileName, CreateLoadInfo(pValue.m_strFileName)); }); return(dicLoadList); }
// 인터페이스 : 리소스 리스트를 Json형태로 번들정보파일포맷으로 쓰기 public static void SaveToResourcesOfBundleFormat(Dictionary <string, SHResourcesTableInfo> dicTable, string strSaveFilePath) { if (0 == dicTable.Count) { return; } string strNewLine = "\r\n"; string strBuff = "{" + strNewLine; // 테이블별 내용작성 strBuff += string.Format("\t\"{0}\": [{1}", "ResourcesList", strNewLine); SHUtils.ForToDic(dicTable, (pKey, pValue) => { strBuff += "\t\t{" + strNewLine; strBuff += string.Format("\t\t\t\"s_BundleName\": \"{0}\",{1}", pValue.m_strName, strNewLine); strBuff += string.Format("\t\t\t\"s_BundleSize\": \"{0}\",{1}", 0, strNewLine); strBuff += string.Format("\t\t\t\"s_BundleHash\": \"{0}\",{1}", 0, strNewLine); strBuff += string.Format("\t\t\t\"p_Resources\": {0}", strNewLine); strBuff += "\t\t\t[" + strNewLine; strBuff += "\t\t\t\t{" + strNewLine; strBuff += SHResourcesLister.MakeSaveFormat(pValue, "\t\t\t\t"); strBuff += "\t\t\t\t}" + strNewLine; strBuff += "\t\t\t]" + strNewLine; strBuff += "\t\t}," + strNewLine; }); strBuff = string.Format("{0}{1}", strBuff.Substring(0, strBuff.Length - (strNewLine.Length + 1)), strNewLine); strBuff += string.Format("\t]{0}", strNewLine); strBuff += "}"; // 저장 SHUtils.SaveFile(strBuff, strSaveFilePath); }
// 유틸 : 언어파일 로드 List <byte> LoadLocalization() { var pByte = new List <byte>(); var pNewLine = System.Text.Encoding.UTF8.GetBytes("\n"); SHUtils.ForToList(m_pLocalFiles, (strFile) => { var pData = Single.Resource.GetTextAsset(strFile); if (null == pData) { return; } pByte.AddRange(pNewLine); pByte.AddRange(pData.bytes); }); return(pByte); }
// 인터페이스 : 바이트파일 컨버터 ( 파일 하나 ) public void ConvertByteFile(SHBaseTable pTable, string strSavePath) { if (null == pTable) { return; } byte[] pBytes = pTable.GetBytesTable(); if (null == pBytes) { return; } SHUtils.SaveByte(pBytes, string.Format("{0}/{1}{2}", strSavePath, pTable.m_strByteFileName, ".bytes")); Debug.Log(string.Format("{0} To Convert Byte Files : {1}", (true == pTable.IsLoadTable() ? "<color=yellow>Success</color>" : "<color=red>Fail!!</color>"), pTable.m_strFileName)); }
void CheckCollision(SHDamageObject pDamage) { if (null == pDamage) { return; } if (false == pDamage.IsCheckCrash()) { return; } SHUtils.ForToList(GetTargets(pDamage), (pTarget) => { var pDamageCollider = pDamage.GetCollider(); var pTargetCollider = pTarget.GetCollider(); if ((null == pDamageCollider) || (null == pTargetCollider)) { return; } var bIsCollistion = false; var bBounds = pDamage.m_pBeforeBounds; for (float fRatio = 0.0f; fRatio <= 1.0f; fRatio += 0.1f) { bBounds.center = SHMath.Lerp(pDamage.m_pBeforeBounds.center, pDamageCollider.bounds.center, fRatio); if (true == bBounds.Intersects(pTargetCollider.bounds)) { bIsCollistion = true; break; } } if (false == bIsCollistion) { return; } pTarget.OnCrashDamage(pDamage); pDamage.OnCrashDamage(pTarget); }); }
// 인터페이스 : Resources폴더 내에 있는 파일을 SHResourceTableData형식에 맞게 Json으로 리스팅 public int SetListing(string strSearchPath) { SHUtils.Search(strSearchPath, (pFileInfo) => { // 파일 정보 생성 SHResourcesTableInfo pInfo = MakeFileInfo(pFileInfo); if (null == pInfo) { return; } // 예외체크 : 파일명 중복 string strDupPath = CheckToDuplication(m_dicResources, pInfo.m_strFileName); if (false == string.IsNullOrEmpty(strDupPath)) { string strFirst = string.Format("{0}", strDupPath); string strSecond = string.Format("{0}", pInfo.m_strPath); #if UNITY_EDITOR EditorUtility.DisplayDialog("[SHTools] Resources Listing", string.Format("중복 파일발견!! 파일명은 중복되면 안됩니다!!\r\n1번 파일을 리스팅 하겠습니다.\r\n1번 : {0}\r\n2번 {1}", strFirst, strSecond), "확인"); #endif if (false == m_dicDuplications.ContainsKey(pInfo.m_strFileName)) { m_dicDuplications[pInfo.m_strFileName] = new List <string>(); m_dicDuplications[pInfo.m_strFileName].Add(strFirst); } m_dicDuplications[pInfo.m_strFileName].Add(strSecond); return; } AddResourceInfo(pInfo); AddAssetBundleInfo(pInfo); }); return(m_dicResources.Count); }
void OnAddUnits() { SHUtils.ForToDic(m_dicAddUnits, (pKey, pValue) => { if (false == m_dicUnits.ContainsKey(pKey)) { m_dicUnits.Add(pKey, new List <SHMonoWrapper>()); } SHUtils.ForToList(pValue, (pUnit) => { if (true == m_dicUnits[pKey].Contains(pUnit)) { return; } m_dicUnits[pKey].Add(pUnit); }); }); m_dicAddUnits.Clear(); }
// Component Missing 체크 public static void CheckMissingComponent() { #if UNITY_EDITOR var pObjects = Resources.FindObjectsOfTypeAll(typeof(GameObject)); SHUtils.ForToArray(pObjects, (pObject) => { if (null == pObject) { return; } SHUtils.ForToArray((pObject as GameObject).GetComponents <Component>(), (pComponent) => { if (null == pComponent) { UnityEngine.Debug.Log(string.Format("<color=red>MissingComponent!!(GameObject{0})</color>", pObject.name)); } }); }); #endif }
// 인터페이스 : 바이트파일 컨버터 ( 파일 하나 ) public bool ConverterByteFile(SHBaseTable pTable, string strSavePath) { if (null == pTable) { return(false); } byte[] pBytes = pTable.GetBytesTable(); if (null == pBytes) { return(false); } SHUtils.SaveByte(pBytes, string.Format("{0}/{1}{2}", strSavePath, pTable.GetFileName(eTableLoadType.Byte), ".bytes")); Debug.Log(string.Format("[LSH] {0} To Converter Byte Files : {1}", (true == pTable.IsLoadTable() ? "<color=yellow>Success</color>" : "<color=red>Fail!!</color>"), pTable.GetFileName(eTableLoadType.Byte))); return(true); }
// 유틸 : 번들정보 스크립트 아웃풋 static void UpdateBundleInfoTable(BuildTarget eTarget, SHTableData pTableData, Dictionary <string, AssetBundleInfo> dicMakeBundles, string strOutputPath) { var pBundleTable = GetBundleTable(pTableData); var pResourceTable = GetResourceTable(pTableData); SHUtils.ForToDic(dicMakeBundles, (pKey, pValue) => { AssetBundleInfo pData = pBundleTable.GetBundleInfo(pValue.m_strBundleName); pData.m_lBundleSize = pValue.m_lBundleSize; pData.m_pHash128 = pValue.m_pHash128; pData.CopyResourceInfo(pValue.m_dicResources); SHUtils.ForToDic(pData.m_dicResources, (pResKey, pResValue) => { pResValue.CopyTo(pResourceTable.GetResouceInfo(pResKey)); }); }); pBundleTable.SaveJsonFileByDic( string.Format("{0}/{1}.json", strOutputPath, pBundleTable.m_strFileName)); }
// 인터페이스 : 리소스 리스트를 Json형태로 쓰기 public static void SaveToResourcesInfo(Dictionary <string, SHResourcesInfo> dicTable, string strSaveFilePath) { if (0 == dicTable.Count) { return; } var pResourcesJsonData = new JsonData(); foreach (var kvp in dicTable) { pResourcesJsonData.Add(MakeResourceJsonData(kvp.Value)); } var pJsonWriter = new JsonWriter(); pJsonWriter.PrettyPrint = true; JsonMapper.ToJson(pResourcesJsonData, pJsonWriter); SHUtils.SaveFile(pJsonWriter.ToString(), strSaveFilePath); }
public override bool?LoadJsonTable(JSONNode pJson, string strFileName) { if (null == pJson) { return(false); } SHUtils.For(0, pJson["PreLoadResourcesList"].Count, (iLoop) => { var pDataNode = pJson["PreLoadResourcesList"][iLoop]; SHUtils.ForToEnum <eSceneType>((eType) => { SHUtils.For(0, pDataNode[eType.ToString()].Count, (iDataIndex) => { AddData(eType, pDataNode[eType.ToString()][iDataIndex].Value); }); }); }); return(true); }
// 인터페이스 : 중복파일 리스트 내보내기 public static void SaveToDuplicationList(Dictionary <string, List <string> > dicDuplications, string strSaveFilePath) { if (0 == dicDuplications.Count) { return; } string strNewLine = "\r\n"; string strBuff = string.Empty; SHUtils.ForToDic(dicDuplications, (pKey, pValue) => { strBuff += string.Format("FileName : {0}{1}", pKey, strNewLine); SHUtils.ForToList(pValue, (strPath) => { strBuff += string.Format("\tPath : Resources/{0}{1}", strPath, strNewLine); }); strBuff += string.Format("{0}", strNewLine); }); SHUtils.SaveFile(strBuff, strSaveFilePath); }
public override Dictionary <string, SHLoadData> GetPatchList() { var dicLoadList = new Dictionary <string, SHLoadData>(); // 서버정보파일(ServerConfiguration.json)에 URL이 없으면 패치하지 않는다. if (true == string.IsNullOrEmpty(SHPath.GetURLToBundleCDN())) { return(dicLoadList); } SHUtils.ForToDic(Single.Table.GetAssetBundleInfo(), (pKey, pValue) => { if (true == IsExist(pKey)) { return; } dicLoadList.Add(pKey, CreatePatchInfo(pValue)); }); return(dicLoadList); }
public void SaveJsonFile(string strSavePath) { string strNewLine = "\r\n"; string strBuff = "{" + strNewLine; strBuff += string.Format("\t\"{0}\": {1}", "ClientConfiguration", strNewLine); strBuff += "\t{" + strNewLine; { strBuff += string.Format("\t\t\"ServerConfigurationCDN\": \"{0}\",{1}", m_strConfigurationCDN, strNewLine); strBuff += string.Format("\t\t\"ServiceMode\": \"{0}\",{1}", m_strServiceMode, strNewLine); strBuff += string.Format("\t\t\"Version\": \"{0}\",{1}", m_strVersion, strNewLine); strBuff += string.Format("\t\t\"VSyncCount\": {0},{1}", m_iVSyncCount, strNewLine); strBuff += string.Format("\t\t\"FrameRate\": {0},{1}", m_iFrameRate, strNewLine); strBuff += string.Format("\t\t\"CacheSize(MB)\": {0}{1}", m_iCacheSize, strNewLine); } strBuff += "\t}"; strBuff += string.Format("{0}", strNewLine); strBuff += "}"; // 저장 SHUtils.SaveFile(strBuff, string.Format("{0}/{1}.json", strSavePath, m_strFileName)); }
public static void DeleteDirectory(string strPath) { DirectoryInfo pDirInfo = new DirectoryInfo(strPath); if (false == pDirInfo.Exists) { return; } FileInfo[] pFiles = pDirInfo.GetFiles("*.*", SearchOption.AllDirectories); SHUtils.ForToArray(pFiles, (pFile) => { if (false == pFile.Exists) { return; } pFile.Attributes = FileAttributes.Normal; }); Directory.Delete(strPath, true); }
private async void OnClickLogin(string strEmail, string strPassword, bool bIsSave) { if (false == SHUtils.IsValidEmail(strEmail)) { var pUIRoot = await Single.UI.GetGlobalRoot(); pUIRoot.ShowAlert("올바른 이메일 형식이 아닙니다."); return; } JsonData json = new JsonData { ["email"] = strEmail, ["password"] = strPassword }; Single.Network.POST(SHAPIs.SH_API_LOGIN, json, async(reply) => { if (reply.isSucceed) { var pUserInfo = await Single.Table.GetTable <SHTableUserInfo>(); pUserInfo.LoadJsonTable(reply.data); SHPlayerPrefs.SetString("auth_email", bIsSave ? pUserInfo.UserEmail : string.Empty); SHPlayerPrefs.SetString("auth_password", bIsSave ? pUserInfo.Password : string.Empty); SHPlayerPrefs.SetInt("auth_is_save", bIsSave ? 1 : 2); SHPlayerPrefs.Save(); } var pUIRoot = await Single.UI.GetGlobalRoot(); pUIRoot.ShowAlert(reply.ToString(), () => { if (reply.isSucceed) { Single.Scene.LoadScene(eSceneType.Lobby, bIsUseFade: true); } }); }); }
// 데이터 셋 생성 // DB에 어떤 시트 어떤 데이터가 있는지 모르는 상태에서 모든 데이터를 string형태로 뽑아 버리는 기능 public Dictionary <string, List <SHTableDataSet> > GetDataSet() { var dicData = new Dictionary <string, List <SHTableDataSet> >(); // 테이블 리스트 생성 var strTableList = "TableList"; var pQuery = GetTable(strTableList); var pTableList = GetTableDataSet(pQuery, strTableList); dicData[strTableList] = pTableList; pQuery.Release(); // 테이블별 데이터 생성 SHUtils.ForToList(pTableList, (pTable) => { string strTableName = pTable.m_pDatas[0]; pQuery = GetTable(strTableName); strTableName = strTableName.Trim('"'); dicData[strTableName] = GetTableDataSet(pQuery, strTableName);; pQuery.Release(); }); return(dicData); }
public void AddLoadInfo(Dictionary <string, SHLoadData> dicLoadList) { SHUtils.ForToDic(dicLoadList, (pKey, pValue) => { // 무결성체크 if (null == pValue) { return; } // 중복파일체크 SHLoadData pLoadData = GetLoadDataInfo(pValue.m_strName); if (null != pLoadData) { Debug.LogError(string.Format("중복파일 발견!!!(FileName : {0})", pValue.m_strName)); return; } // 초기화 및 등록 SetLoadData(pValue); m_pLoadCount.Value1++; }); }
// 인터페이스 : 원본 리소스들의 GUID를 기록한다. public void ReadyGUID() { m_dicGUID.Clear(); SHUtils.Search(SHPath.GetPathToResources(), (pFileInfo) => { string strExtension = Path.GetExtension(pFileInfo.FullName); if (".meta" == strExtension.ToLower()) { return; } if (true == m_dicGUID.ContainsKey(pFileInfo.FullName)) { return; } string strRoot = "Assets"; string strFullName = pFileInfo.FullName.Substring(pFileInfo.FullName.IndexOf(strRoot)).Replace("\\", "/"); string strGUID = AssetDatabase.AssetPathToGUID(strFullName); m_dicGUID.Add(strFullName, strGUID); }); }
List <SHMonoWrapper> GetTargets(SHDamageObject pDamage) { if (null == pDamage) { return(null); } var pTargets = new List <SHMonoWrapper>(); SHUtils.ForToDic(m_dicUnits, (pKey, pValue) => { SHUtils.ForToList(pValue, (pUnit) => { if (false == pDamage.IsTarget(pUnit.tag)) { return; } pTargets.Add(pUnit); }); }); return(pTargets); }
// 인터페이스 : DataSet을 Json으로 쓰기 public void Write(string strFileName, Dictionary <string, List <SHTableDataSet> > dicData) { #if UNITY_EDITOR if (null == dicData) { Debug.LogError(string.Format("Json으로 저장할 데이터가 없습니다!!")); return; } string strNewLine = "\r\n"; string strBuff = "{" + strNewLine; SHUtils.ForToDic(dicData, (pKey, pValue) => { strBuff += string.Format("\t\"{0}\": [{1}", pKey, strNewLine); SHUtils.ForToList(pValue, (pData) => { strBuff += "\t\t{" + strNewLine; SHUtils.For(0, pData.m_iMaxCol, (iCol) => { strBuff += string.Format("\t\t\t\"{0}\": {1},{2}", pData.m_ColumnNames[iCol], pData.m_pDatas[iCol], strNewLine); }); strBuff = string.Format("{0}{1}", strBuff.Substring(0, strBuff.Length - (strNewLine.Length + 1)), strNewLine); strBuff += "\t\t}," + strNewLine; }); strBuff = string.Format("{0}{1}", strBuff.Substring(0, strBuff.Length - (strNewLine.Length + 1)), strNewLine); strBuff += string.Format("\t],{0}", strNewLine); }); strBuff = string.Format("{0}{1}", strBuff.Substring(0, strBuff.Length - (strNewLine.Length + 1)), strNewLine); strBuff += "}"; SHUtils.SaveFile(strBuff, string.Format("{0}/{1}.json", SHPath.GetPathToJson(), Path.GetFileNameWithoutExtension(strFileName))); #endif }
// 이벤트 : 클릭 이벤트 void OnCliSH() { if (null == m_pLabel) { return; } var strURL = m_pLabel.GetUrlAtPosition(UICamera.lastHit.point); if (true == string.IsNullOrEmpty(strURL)) { return; } if (true == m_bIsAutoOpenURL) { Application.OpenURL(strURL); } SHUtils.ForToList(m_pEvent, (pEvent) => { pEvent(strURL); }); }
void PlaySound(eDamageEvent eEvent) { SHUtils.ForToList(m_pInfo.m_pSoundInfo, (pInfo) => { switch (eEvent) { case eDamageEvent.Tick: if (m_pInfo.m_iLifeTick == pInfo.m_iPlayToLifeTick) { Single.Sound.PlayEffect(pInfo.m_strClipName); } break; case eDamageEvent.Start: if (true == pInfo.m_bIsPlayToStart) { Single.Sound.PlayEffect(pInfo.m_strClipName); } break; case eDamageEvent.Delete: if (true == pInfo.m_bIsPlayToDelete) { Single.Sound.PlayEffect(pInfo.m_strClipName); } break; case eDamageEvent.Crash: if (true == pInfo.m_bIsPlayToCrash) { Single.Sound.PlayEffect(pInfo.m_strClipName); } break; } }); }
public void Write(string strFileName, Dictionary <string, List <SHTableDataSet> > dicData) { if (null == dicData) { Debug.LogError(string.Format("SQLite로 저장할 데이터가 없습니다!!")); return; } string strSavePath = string.Format("{0}/{1}.db", SHPath.GetPathToSQLite(), Path.GetFileNameWithoutExtension(strFileName)); File.Delete(strSavePath); try { m_pSQLiteDB = new SQLiteDB(); m_pSQLiteDB.Open(strSavePath); SHUtils.ForToDic(dicData, (pKey, pValue) => { // 테이블 생성 if (false == CreateTable(pKey, pValue[0])) { return; } // 생성한 테이블에 데이터 인설트 if (false == InsertData(pKey, pValue)) { return; } }); } catch (System.Exception e) { Debug.LogError(string.Format("SQLite Read Fail : {0}", e.ToString())); } }
public void SendEventToCollision(SHDamageObject pDamage) { SHUtils.ForToList(m_pEventToCollision, (pCallback) => pCallback(pDamage)); }