Advertisement
eduardogr

Untitled

Sep 11th, 2021
666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1.  
  2. using System.Collections.Generic;
  3.  
  4. using UnityEditor;
  5.  
  6. using UnityEngine;
  7.  
  8.  
  9. public class CreateFolders : EditorWindow {
  10.  
  11.     private float _space = 20f;
  12.  
  13.     private List<string> list = new List<string>();
  14.  
  15.     [MenuItem("Unity/Create structure")]
  16.     static void CreateFolder() {
  17.  
  18.         GetWindow<CreateFolders>("Create your structure");
  19.     }
  20.  
  21.     private void OnGUI() {
  22.  
  23.         GUILayout.Label("Here you can write the names of your folders", EditorStyles.largeLabel);
  24.  
  25.         GUILayout.Space(_space);
  26.  
  27.         Debug.Log(list.Count);
  28.  
  29.         for (int i = 0; i < list.Count; i++) {
  30.             list[i] = GUILayout.TextField(list[i]);
  31.         }
  32.  
  33.         if (GUILayout.Button("Add folder")) {
  34.             list.Add("");
  35.         }
  36.  
  37.         if (GUILayout.Button("Create structure")) {
  38.             foreach (var item in list) {
  39.                 if (AssetDatabase.IsValidFolder($"Assets/{item}")) {
  40.                     return;
  41.                 }
  42.                 string folders = AssetDatabase.CreateFolder("Assets", item);
  43.                 AssetDatabase.GUIDToAssetPath(folders);
  44.             }
  45.         }
  46.  
  47.         if (GUILayout.Button("Close")) {
  48.             Close();
  49.         }
  50.     }
  51.  
  52.     [MenuItem("Unity/Organize files")]
  53.     static void OrganizeFiles() {
  54.  
  55.     }
  56. }
  57.  
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement