static void _MakeAtlas() { //Debug.Log(string.Format("UI Texture To Prefab")); string spriteDir = Application.dataPath + "/Resources/UI/Sprites/"; var filesPath = GKFileUtil.GetFilesInDirectory(Application.dataPath + "/Art/_UI/Sprite2Prefab/"); foreach (var str in filesPath) { if (string.Empty != GKString.GetFromSuffix(str, ".png", true) || string.Empty != GKString.GetFromSuffix(str, ".jpg", true)) { string allPath = str; string assetPath = allPath.Substring(allPath.IndexOf("Assets")); Sprite sprite = AssetDatabase.LoadAssetAtPath <Sprite>(assetPath); GameObject go = new GameObject(sprite.name); go.AddComponent <SpriteRenderer>().sprite = sprite; var dir = GKFileUtil.GetDirctoryName(allPath); allPath = string.Format("{0}{1}/{2}.prefab", spriteDir, dir, sprite.name); GKFileUtil.CreateDirectoryFromFileName(allPath); string prefabPath = allPath.Substring(allPath.IndexOf("Assets")); PrefabUtility.CreatePrefab(prefabPath, go); GameObject.DestroyImmediate(go); } } }
static public int GetArrayElementPropIndex(SerializedProperty prop) { var ext = System.IO.Path.GetExtension(prop.propertyPath); var s = GKString.GetFromPrefix(ext, ".data[", false); if (string.IsNullOrEmpty(s)) { return(-1); } s = GKString.GetFromSuffix(s, "]", false); if (string.IsNullOrEmpty(s)) { return(-2); } int i; if (!int.TryParse(s, out i)) { return(-3); } return(i); }