// private void LoadSprite() { countLoadSprite = 0; loadingSpriteNameList.Clear(); string fullPath = Application.dataPath + "/" + RESOURCES_PATH + "/" + SPRITE_PATH + "/"; // Sprite Directory 이하의 Directory 들을 가져옴 string[] targetDirectoryWithPath = System.IO.Directory.GetDirectories(fullPath); List <string> targetDirectoryWithPathList = new List <string>(targetDirectoryWithPath); targetDirectoryWithPathList.Add(fullPath); for (int i = 0; i < targetDirectoryWithPathList.Count; ++i) { // directory 들 이하의 png file 들을 가져옴 string[] spriteNameWithPath = System.IO.Directory.GetFiles(targetDirectoryWithPathList[i], "*.png"); CustomLog.CompleteLog("Sprite Root: " + targetDirectoryWithPathList[i]); for (int j = 0; j < spriteNameWithPath.Length; ++j) { if (spriteNameWithPath[j].Substring(0, 1) == EXCLUDE_KEYWORD) { continue; } // 4 파트로 나뉜 이름 string[] strType = { "", "", "", "" }; string[] splitName = GetSplitName(spriteNameWithPath[j]); // 소문자로 설정 ToLowerNames(ref splitName); for (int k = 0; k < Mathf.Min(4, splitName.Length); ++k) { strType[k] = splitName[k]; } SpriteAttribute sa = new SpriteAttribute(); // resource.load 를 위한 이름 string resourceLoadName = GetLoadingName(spriteNameWithPath[j]); sa.sprite = Resources.Load <Sprite>(resourceLoadName); if (GetSpriteAttribute(strType) == "") { sa.isAnimation = false; } else { sa.isAnimation = true; sa.frameCount = GetSpriteFrameCount(strType); sa.speed = GetSpriteSpeed(strType); sa.length = (1f / (float)spriteDefaultFramePerSec) / sa.speed * (float)(sa.frameCount - 1); } CutSpriteAttribute(ref strType); // if (sa.sprite == null) { CustomLog.CompleteLogWarning( "Invalid Sprite: " + resourceLoadName, PRINT_DEBUG); continue; } loadingSpriteNameList.Add(strType[0] + " " + strType[1] + " " + strType[2]); string category = strType[0]; string name = strType[1]; string status = strType[2]; if (typeSpriteDic.ContainsKey(category) == false) { typeSpriteDic.Add(category, new Dictionary <string, Dictionary <string, SpriteAttribute> >()); } if (typeSpriteDic[category].ContainsKey(name) == false) { typeSpriteDic[category].Add(name, new Dictionary <string, SpriteAttribute>()); } if (typeSpriteDic[category][name].ContainsKey(status) == false) { typeSpriteDic[category][name].Add(status, sa); } ++countLoadSprite; } } for (int i = 0; i < targetDirectoryWithPathList.Count; ++i) { string[] controllerNameWithPath = System.IO.Directory.GetFiles(targetDirectoryWithPathList[i], "*.controller"); // load 된 sprite 가 animation 이면 attribute 에 controller 추가 for (int k = 0; k < controllerNameWithPath.Length; ++k) { string[] strTypeController = { "", "", "" }; string[] splitControllerName = GetSplitName(controllerNameWithPath[k]); // 소문자로 설정 ToLowerNames(ref splitControllerName); for (int l = 0; l < Mathf.Min(3, splitControllerName.Length); ++l) { strTypeController[l] = splitControllerName[l]; } CutSpriteAttribute(ref strTypeController); SpriteAttribute sa = GetSpriteAttribute(strTypeController[0], strTypeController[1], strTypeController[2]); if (sa != null) { if (sa.isAnimation == true) { string controllerLoadName = GetLoadingName(controllerNameWithPath[k]); sa.controller = Instantiate(Resources.Load <RuntimeAnimatorController>(controllerLoadName)); } } } } CustomLog.CompleteLog("Load Sprite Count: " + countLoadSprite); }