Created
May 11, 2019 18:43
-
-
Save ninpl/ffc6e8abbd296f0b313d97446baea593 to your computer and use it in GitHub Desktop.
Metodo que genera una ruta de directorios pasandole la ruta por texto.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region | |
#if UNITY_EDITOR | |
using UnityEditor; | |
using System.IO; | |
#endif | |
#endregion | |
namespace AntonioMoon | |
{ | |
/// <summary> | |
/// <para>Clase que contiene funcionalidad diversa para utilizarla en el Editor.</para> | |
/// </summary> | |
public static class Utilidades | |
{ | |
#if UNITY_EDITOR | |
#region API | |
/// <summary> | |
/// <para>Crea una estructura de carpetas con una ruta mandada.</para> | |
/// </summary> | |
/// <param name="ruta">Ruta que se creara.</param> | |
public static void CrearEstructuraCarpetas(string ruta) | |
{ | |
string[] rutaSplit = ruta.Split(new char[] { '/', '\\' }, System.StringSplitOptions.RemoveEmptyEntries); | |
string rutaStack = rutaSplit[0]; | |
for (int n = 1; n < rutaSplit.Length; n++) | |
{ | |
string carpeta = rutaSplit[n]; | |
string rutaIndex = Path.Combine(rutaStack, carpeta); | |
if (!AssetDatabase.IsValidFolder(rutaIndex)) | |
{ | |
string guid = AssetDatabase.CreateFolder(rutaStack, carpeta); | |
rutaStack = AssetDatabase.GUIDToAssetPath(guid); | |
} | |
else | |
{ | |
rutaStack = Path.Combine(rutaStack, carpeta); | |
} | |
} | |
} | |
#endregion | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment