public void SaveLoadResourceList() { // var pJsonData = new JsonData(); // foreach (var kvp in m_pDicResourceLoadInfo) // { // foreach (var pValue in kvp.Value) // { // pJsonData[string.Format("Scene : {0}", kvp.Key)].Add(pValue); // } // } // var pJsonWriter = new JsonWriter(); // pJsonWriter.PrettyPrint = true; // JsonMapper.ToJson(pJsonData, pJsonWriter); // string strSavePath = string.Format("{0}/{1}.json", SHPath.GetAssets(), "RealTimeResourceLoadInfo"); // SHUtils.SaveFile(pJsonWriter.ToString(), strSavePath); string strBuff = string.Empty; foreach (var kvp in m_pDicResourceLoadInfo) { foreach (var pValue in kvp.Value) { strBuff += string.Format("Scene : {0}\n{1}\n", kvp.Key, pValue); } } string strSavePath = string.Format("{0}/{1}.txt", SHPath.GetRoot(), "RealTimeResourceLoadInfo"); SHUtils.SaveFile(strBuff, strSavePath); Process.Start(strSavePath); }
static void AllFilsInResourcesFolderWithAssetBundleInfo() { // 시작팝업 if (false == ShowDialog("[SHTools] Update Resources Info", SHEditorResourcesLister.m_strMsg_1, "확인", "취소")) { return; } // 알리아싱 var pStartTime = DateTime.Now; var strSaveResourcePath = string.Format("{0}/{1}", SHPath.GetResourceJsonTable(), "JsonResourcesInfo.json"); //var strSaveBundlePath = string.Format("{0}/{1}", SHPath.GetResourceJsonTable(), "JsonAssetBundleInfo.json"); var strSaveDuplicationPath = string.Format("{0}/{1}", SHPath.GetRoot(), "DuplicationResourcesList.txt"); // 리스팅 var pLister = new SHResourcesLister(); var iFileCount = pLister.Listing(SHPath.GetResources()); SHResourcesLister.SaveToResourcesInfo(pLister.m_dicResources, strSaveResourcePath); //SHResourcesLister.SaveToAssetBundleInfo(pLister.m_dicAssetBundles, strSaveBundlePath); SHResourcesLister.SaveToDuplicationList(pLister.m_dicDuplications, strSaveDuplicationPath); // 종료팝업 if (true == ShowDialog("[SHTools] Update Resources Info", string.Format(SHEditorResourcesLister.m_strMsg_2, iFileCount, strSaveResourcePath, ((DateTime.Now - pStartTime).TotalMilliseconds / 1000.0)), "파일확인", "닫기")) { System.Diagnostics.Process.Start(strSaveResourcePath); } }
public SHXML(string strFileName) { if (true == string.IsNullOrEmpty(strFileName)) { return; } strFileName = Path.GetFileNameWithoutExtension(strFileName); // 에디터상 실행이 안된 상태 ( Convert툴로 실행 )에서 호출이 되었을 경우 // SHDataManager가 생성되면 하이어라키에 싱글턴 찌꺼기가 남기 때문에 다이렉트로 로드할 수 있도록 한다. TextAsset pTextAsset = null; if (false == SHDataManager.IsExists) { string strResources = "Resources"; string strFilePath = string.Format("{0}/{1}", SHPath.GetPathToXML(), strFileName); strFilePath = strFilePath.Substring(strFilePath.IndexOf(strResources) + strResources.Length + 1).Replace('\\', '/'); pTextAsset = Resources.Load <TextAsset>(strFilePath); } else { pTextAsset = Single.Resource.GetTextAsset(strFileName); } if (null != pTextAsset) { SetXMLData(pTextAsset.text); } }
// 유틸 : 저장경로 얻기 string GetOutputPath() { GUILayout.BeginVertical("Box"); GUILayout.Label("Select Output Path", EditorStyles.boldLabel); EditorGUILayout.HelpBox(m_strOutputPath, MessageType.None); if (true == GUILayout.Button("Defualt Output Path")) { m_strOutputPath = SHPath.GetPathToExportAssetBundle(); } if (true == GUILayout.Button("Change Output Path")) { string strChangePath = EditorUtility.OpenFolderPanel("Select Bundle Save Folder", "", ""); if (false == string.IsNullOrEmpty(strChangePath)) { m_strOutputPath = strChangePath; } } if (true == GUILayout.Button("Open Output Path")) { SHUtils.OpenInFileBrowser(m_strOutputPath); } GUILayout.EndVertical(); return(m_strOutputPath); }
static void BuildApplication(string[] strScenes, BuildTarget eTarget, BuildOptions eOptions) { string strBuildName = GetBuildName(eTarget, Single.AppInfo.GetProductName()); Debug.LogFormat("** [SHBuilder] Build Start({0}) -> {1}", strBuildName, DateTime.Now.ToString("yyyy-MM-dd [ HH:mm:ss ]")); { if (BuildTarget.Android == eTarget) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, eTarget); } else { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, eTarget); } string strExportPath = string.Format("{0}/{1}/{2}", SHPath.GetBuild(), SHUtils.GetPlatformStringByEnum(eTarget), strBuildName); SHUtils.CreateDirectory(strExportPath); BuildReport pReport = BuildPipeline.BuildPlayer(strScenes, strExportPath, eTarget, eOptions); if (BuildResult.Failed == pReport.summary.result) { throw new Exception("[SHBuilder] BuildPlayer failure: BuildPipeline.BuildPlayer"); } } Debug.LogFormat("** [SHBuilder] Build End({0}) -> {1}", strBuildName, DateTime.Now.ToString("yyyy-MM-dd [ HH:mm:ss ]")); }
// 유틸 : App 빌드 static void BuildApplication(string[] strScenes, BuildTarget eTarget, BuildOptions eOptions) { string strBuildName = GetBuildName(eTarget, Single.AppInfo.GetAppName(), Single.Table.GetClientVersion()); Debug.LogFormat("** Build Start({0}) -> {1}", strBuildName, DateTime.Now.ToString("yyyy-MM-dd [ HH:mm:ss ]")); { EditorUserBuildSettings.SwitchActiveBuildTarget(eTarget); string strFileName = string.Format("{0}/{1}", SHPath.GetPathToBuild(), strBuildName); if (false == SHUtils.IsExistsDirectory(strFileName)) { eOptions = BuildOptions.None; } SHUtils.CreateDirectory(strFileName); string strResult = BuildPipeline.BuildPlayer(strScenes, strFileName, eTarget, eOptions); if (0 < strResult.Length) { throw new Exception("BuildPlayer failure: " + strResult); } } Debug.LogFormat("** Build End({0}) -> {1}", strBuildName, DateTime.Now.ToString("yyyy-MM-dd [ HH:mm:ss ]")); }
public override void Patch(SHLoadData pInfo, Action <string, SHLoadStartInfo> pStart, Action <string, SHLoadEndInfo> pDone) { if (true == IsExist(pInfo.m_strName)) { pStart(pInfo.m_strName, new SHLoadStartInfo()); pDone(pInfo.m_strName, new SHLoadEndInfo(true, eLoadErrorCode.None)); return; } WWW pAsync = Single.Coroutine.WWW((pWWW) => { bool bIsSuccess = string.IsNullOrEmpty(pWWW.error); if (true == bIsSuccess) { AddBundleData(pInfo.m_strName, pWWW.assetBundle); pDone(pInfo.m_strName, new SHLoadEndInfo(true, eLoadErrorCode.None)); } else { pDone(pInfo.m_strName, new SHLoadEndInfo(false, eLoadErrorCode.Patch_Bundle)); } }, WWW.LoadFromCacheOrDownload(string.Format("{0}/{1}.unity3d", SHPath.GetURLToBundleCDNWithPlatform(), pInfo.m_strName.ToLower()), Single.Table.GetAssetBundleInfo(pInfo.m_strName).m_pHash128)); pStart(pInfo.m_strName, new SHLoadStartInfo(pAsync)); }
public SHBytes(string strFileName, Action <SHBytes> pCallback) { if (true == string.IsNullOrEmpty(strFileName)) { pCallback(this); return; } strFileName = Path.GetFileNameWithoutExtension(strFileName); // 1차 : PersistentDataPath에 데이터가 있으면 그걸 로드하도록 한다. // 2차 : 없으면 패키지에서 로드하도록 한다. string strSavePath = string.Format("{0}/{1}.bytes", SHPath.GetPersistentDataBytes(), strFileName); if (true == File.Exists(strSavePath)) { LoadByPersistent(strSavePath, (pBytes) => { m_pBytes = pBytes; pCallback(this); }); } else { LoadByPackage(strFileName, (pBytes) => { m_pBytes = pBytes; pCallback(this); }); } }
// 인터페이스 : 에디터 클래스 전용 ( Resources폴더내에 컨버팅된 Byte파일을 쏟아 냄 ) public void RunEditorToConverter() { var pTableData = new SHTableData(); pTableData.OnInitialize(); ConverterTableToByte(pTableData, SHPath.GetResourceByteTable()); pTableData.OnFinalize(); }
// 인터페이스 : 에디터 클래스 전용 ( Resources폴더내에 컨버팅된 Byte파일을 쏟아 냄 ) public void RunEditorToConvert() { var pTableData = new SHTableData(); pTableData.OnInitialize(); ConvertByteFiles(pTableData, string.Format("{0}{1}", SHPath.GetPathToResources(), "/Table/Bytes")); pTableData.OnFinalize(); }
static void SelectMenu() { m_pEditorWindow = EditorWindow.GetWindow(typeof(SHEditorAssetBundleMaker)); m_pEditorWindow.autoRepaintOnSceneChange = true; m_pEditorWindow.ShowUtility(); m_strOutputPath = SHPath.GetPathToExportAssetBundle(); m_iSelPlatformType = 0; m_bIsDeleteOriginal = false; }
static void SelectFiles() { // 시작팝업 if (false == ShowDialog("[SHTools] Prefab Dependency Check", "리소스 폴더 내에 있는 원본 리소스들이\n선택한 프리팹에 종속되어 있는지 체크합니다.", "확인", "취소")) { return; } // 선택 오브젝트 체크 var pObjects = new List <UnityEngine.Object>(Selection.objects); if (0 == pObjects.Count) { ShowDialog("[SHTools] Resources Listing", "선택된 프리팹이 없습니다.", "확인"); return; } // 알리아싱 var pChecker = new SHPrefabDependencyChecker(); // 절대경로처리 var strAbsolutePath = SHPath.GetPathToAssets(); strAbsolutePath = strAbsolutePath.Substring(0, (strAbsolutePath.IndexOf("Assets") - 1)).Replace("\\", "/"); // 종속체크 string strBuff = string.Empty; SHUtils.ForToList(pObjects, (pObject) => { string strSearchPath = string.Format("{0}/{1}", strAbsolutePath, AssetDatabase.GetAssetPath(pObject)); SHUtils.Search(strSearchPath, (pFileInfo) => { var pDependencys = pChecker.GetDependency(pFileInfo.FullName); if (null == pDependencys) { return; } strBuff += string.Format("< Prefab : {0} >\n", Path.GetFileNameWithoutExtension(pFileInfo.FullName)); SHUtils.ForToList(pDependencys, (pDependency) => { strBuff += string.Format(" Dependency : {0}\n", pDependency); }); }); }); string strSavePath = string.Format("{0}/{1}", strAbsolutePath, "DependencyList.txt"); SHUtils.SaveFile(strBuff, strSavePath); System.Diagnostics.Process.Start(strSavePath); }
// 인터페이스 : Streaming에서 LoaclLoad로 로드 public JSONNode LoadToStreamingForLocal(string strFileName) { string strSavePath = string.Format("{0}/{1}.json", SHPath.GetPathToJson(), Path.GetFileNameWithoutExtension(strFileName)); if (false == File.Exists(strSavePath)) { return(null); } return(SetJsonNode(LoadLocal(strSavePath))); }
static void PackingAssetBundles(BuildTarget eTarget, eBundlePackType eType) { Debug.LogFormat("** [SHBuilder] AssetBundles Packing Start({0}) -> {1}", eTarget, DateTime.Now.ToString("yyyy-MM-dd [ HH:mm:ss ]")); { string strExportPath = string.Format("{0}/{1}/{2}", SHPath.GetBuild(), SHUtils.GetPlatformStringByEnum(eTarget), "AssetBundle"); SHUtils.CreateDirectory(strExportPath); BuildPipeline.BuildAssetBundles(strExportPath, BuildAssetBundleOptions.None, eTarget); } Debug.LogFormat("** [SHBuilder] AssetBundles Packing End({0}) -> {1}", eTarget, DateTime.Now.ToString("yyyy-MM-dd [ HH:mm:ss ]")); }
public void DownloadServerConfiguration(Action pComplate) { var pTable = GetTable <JsonServerConfiguration>(); if (null == pTable) { pComplate(); return; } pTable.DownloadByCDN(pComplate, SHPath.GetURLToServerConfigurationCDN()); }
// 유틸 : 원본 리소스 모두 제거 static void DeleteOriginalResource(SHTableData pTableData) { var pBundleInfo = GetBundleTable(pTableData); SHUtils.ForToDic(pBundleInfo.GetContainer(), (pKey, pValue) => { SHUtils.ForToDic(pValue.m_dicResources, (pResKey, pResValue) => { SHUtils.DeleteFile(string.Format("{0}/{1}{2}", SHPath.GetPathToResources(), pResValue.m_strPath, pResValue.m_strExtension)); SHUtils.DeleteFile(string.Format("{0}/{1}{2}", SHPath.GetPathToResources(), pResValue.m_strPath, ".meta")); }); }); }
private static string GetStreamingPath(string strFileName) { string strPath = string.Empty; #if UNITY_EDITOR || UNITY_STANDALONE strPath = string.Format("{0}{1}", "file://", SHPath.GetStreamingAssets()); #elif UNITY_ANDROID strPath = string.Format("{0}{1}{2}", "jar:file://", SHPath.GetAssets(), "!/assets"); #elif UNITY_IOS strPath = string.Format("{0}{1}{2}", "file://", SHPath.GetAssets(), "/Raw"); #endif return(string.Format("{0}/Json/{1}.json", strPath, Path.GetFileNameWithoutExtension(strFileName))); }
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); }
static void SelectFiles() { // 시작팝업 if (false == ShowDialog("[SHTools] Resources Listing", SHEditorResourcesLister.m_strMsg_2, "확인", "취소")) { return; } // 선택 오브젝트 체크 var pObjects = Selection.objects; if ((null == pObjects) || (0 == pObjects.Length)) { ShowDialog("[SHTools] Resources Listing", "선택된 오브젝트가 없습니다.", "확인"); return; } // 알리아싱 int iFileCount = 0; var pStartTime = DateTime.Now; var pLister = new SHResourcesLister(); // 절대경로처리 var strAbsolutePath = SHPath.GetPathToAssets(); strAbsolutePath = strAbsolutePath.Substring(0, (strAbsolutePath.IndexOf("Assets") - 1)).Replace("\\", "/"); // 리스팅 for (int iLoop = 0; iLoop < pObjects.Length; ++iLoop) { iFileCount += pLister.SetListing( string.Format("{0}/{1}", strAbsolutePath, AssetDatabase.GetAssetPath(pObjects[iLoop]))); } var strSavePath = string.Format("{0}/{1}", strAbsolutePath, "SelectFiles.txt"); SHResourcesLister.SaveToResources(pLister.m_dicResources, strSavePath); // 종료팝업 ShowDialog("[SHTools] Resources Listing", string.Format(SHEditorResourcesLister.m_strMsg_3, iFileCount, strSavePath, ((DateTime.Now - pStartTime).TotalMilliseconds / 1000.0)), "확인"); System.Diagnostics.Process.Start(strSavePath); }
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 SHBytes(string strFileName) { if (true == string.IsNullOrEmpty(strFileName)) { return; } strFileName = Path.GetFileNameWithoutExtension(strFileName); // 1차 : PersistentDataPath에 Byte데이터가 있으면 그걸 로드하도록 한다. // 2차 : 없으면 패키지에서 로드하도록 한다. string strSavePath = string.Format("{0}/{1}.bytes", SHPath.GetPathToPersistentByte(), strFileName); if (true == File.Exists(strSavePath)) { m_pBytes = LoadLocal(strSavePath); } else { m_pBytes = LoadPackage(strFileName); } }
// 인터페이스 : 원본 리소스들의 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); }); }
// 인터페이스 : CDN에서 정보파일 다운로드 public void DownloadByCDN(Action pComplate, string strURL) { // URL이 없으면 다운받지 않는다. if (true == string.IsNullOrEmpty(strURL)) { pComplate(); return; } Single.Coroutine.WWW((pWWW) => { if (true == string.IsNullOrEmpty(pWWW.error)) { SHJson pJson = new SHJson(); pJson.SetJsonNode(pJson.GetJsonParseToString(pWWW.text)); LoadJsonTable(pJson.Node, m_strFileName); pComplate(); } else { Debug.LogErrorFormat("Error!!! Download ServerConfiguration.json : (Error : {0}, URL : {1}", pWWW.error, pWWW.url); } }, new WWW(string.Format("{0}/{1}.json", SHPath.GetURLToServerConfigurationCDN(), m_strFileName))); }
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 DownloadByCDN(Action pComplate) { // 서버정보파일(ServerConfiguration.json)에 URL이 없으면 패치하지 않는다. if (true == string.IsNullOrEmpty(SHPath.GetURLToBundleCDN())) { pComplate(); return; } Single.Coroutine.WWW((pWWW) => { if (true == string.IsNullOrEmpty(pWWW.error)) { SHJson pJson = new SHJson(); pJson.SetJsonNode(pJson.GetJsonParseToByte(pWWW.bytes)); LoadJsonTable(pJson.Node, m_strFileName); pComplate(); } else { Debug.LogErrorFormat("Error!!! Download AssetBundleInfo.json : (Error : {0}, URL : {1}", pWWW.error, pWWW.url); } }, new WWW(string.Format("{0}/{1}.json", SHPath.GetURLToBundleCDNWithPlatform(), m_strFileName))); }
// 인터페이스 : 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 }
// 경로 : (Assets/StreamingAssets/Json) public static string GetStreamingAssetsJsonTable() { return(string.Format("{0}/{1}", SHPath.GetStreamingAssets(), "Json")); }
// 경로 : (Assets/Resources/Table/Json) public static string GetResourceJsonTable() { return(string.Format("{0}/{1}/{2}", SHPath.GetResources(), "Table", "Json")); }
// 경로 : (사용자디렉토리 : /AppData/LocalLow/회사이름/프로덕트이름/플랫폼/Json) public static string GetPersistentDataXML() { return(string.Format("{0}/{1}", SHPath.GetPersistentData(), "XML")); }
// 경로 : (사용자디렉토리 : /AppData/LocalLow/회사이름/프로덕트이름/플랫폼/Json) public static string GetPersistentDataJson() { return(string.Format("{0}/{1}", SHPath.GetPersistentData(), "Json")); }