├── CreateProjectTree.cs ├── CreateProjectTree.cs.meta ├── LICENSE ├── LICENSE.meta ├── README.md └── README.md.meta /CreateProjectTree.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using System.IO; 5 | 6 | namespace ProjectTreeGenerator 7 | { 8 | class Folder 9 | { 10 | public string DirPath { get; private set; } 11 | public string ParentPath { get; private set; } 12 | public string Name; 13 | public List Subfolders; 14 | 15 | public Folder Add(string name) 16 | { 17 | Folder subfolder = null; 18 | if (ParentPath.Length > 0) 19 | subfolder = new Folder(name, ParentPath + Path.DirectorySeparatorChar + Name); 20 | else 21 | subfolder = new Folder(name, Name); 22 | 23 | Subfolders.Add(subfolder); 24 | return subfolder; 25 | } 26 | 27 | public Folder(string name, string dirPath) 28 | { 29 | Name = name; 30 | ParentPath = dirPath; 31 | DirPath = ParentPath + Path.DirectorySeparatorChar + Name; 32 | Subfolders = new List(); 33 | } 34 | } 35 | 36 | public class CreateProjectTree 37 | { 38 | 39 | [MenuItem("Tools/Generate Project Tree")] 40 | public static void Execute() 41 | { 42 | var assets = GenerateFolderStructure(); 43 | CreateFolders(assets); 44 | } 45 | 46 | private static void CreateFolders(Folder rootFolder) 47 | { 48 | if (!AssetDatabase.IsValidFolder(rootFolder.DirPath)) 49 | { 50 | Debug.Log("Creating: " + rootFolder.DirPath + ""); 51 | AssetDatabase.CreateFolder(rootFolder.ParentPath, rootFolder.Name); 52 | File.Create(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + rootFolder.DirPath + Path.DirectorySeparatorChar + ".keep"); 53 | } 54 | else 55 | { 56 | if (Directory.GetFiles(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + rootFolder.DirPath).Length < 1) 57 | { 58 | File.Create(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + rootFolder.DirPath + Path.DirectorySeparatorChar + ".keep"); 59 | Debug.Log("Creating '.keep' file in: " + rootFolder.DirPath + ""); 60 | } 61 | else 62 | { 63 | Debug.Log("Directory " + rootFolder.DirPath + " already exists"); 64 | } 65 | } 66 | 67 | foreach (var folder in rootFolder.Subfolders) 68 | { 69 | CreateFolders(folder); 70 | } 71 | } 72 | 73 | private static Folder GenerateFolderStructure() 74 | { 75 | Folder rootFolder = new Folder("Assets", ""); 76 | rootFolder.Add("Scripts"); 77 | rootFolder.Add("Scenes"); 78 | rootFolder.Add("Extensions"); 79 | rootFolder.Add("Resources"); 80 | rootFolder.Add("Plugins"); 81 | 82 | var staticAssets = rootFolder.Add("StaticAssets"); 83 | staticAssets.Add("Animations"); 84 | staticAssets.Add("Animators"); 85 | staticAssets.Add("Effects"); 86 | staticAssets.Add("Fonts"); 87 | staticAssets.Add("Materials"); 88 | staticAssets.Add("Models"); 89 | staticAssets.Add("Prefabs"); 90 | staticAssets.Add("Shaders"); 91 | staticAssets.Add("Sounds"); 92 | staticAssets.Add("Sprites"); 93 | staticAssets.Add("Textures"); 94 | staticAssets.Add("Videos"); 95 | 96 | return rootFolder; 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /CreateProjectTree.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 31b2c25921852e04eb361636a0917a01 3 | timeCreated: 1444154861 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Daniel Koprowski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a20cd8280ad2e04ba633914dc88e863 3 | timeCreated: 1444162201 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity project tree generator 2 | This script will generate basic folder structure for your Unity3D project. 3 | 4 | Take a look at my [blog post](http://koprowski.it/2016/unity-project-directories/) for more information about this plugin. 5 | ## Installation 6 | Simply clone this repo into your `Assets/Editor/*` directory. 7 | 8 | _If you don't have `Editor` folder - create it_ 9 | ## Usage 10 | When you have cloned the repository look at your Unity. There is a new option in your toolbar. 11 | Choose `Tools/Generate Project Tree` and enjoy. 12 | 13 | ## Contribution 14 | Feel free to adjust this tool to your needs. 15 | To change folder structure look at `GenerateFolderStructure` method in `CreateProjectTree` class. 16 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c98b18c1a3144ac4e9494737776f6392 3 | timeCreated: 1444168229 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | --------------------------------------------------------------------------------