Create project directories

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Removing all content from page)
m (Reverted edits by Joseph05408 (Talk); changed back to last version by Almar)
Line 1: Line 1:
 +
[[Category: Editor]]
 +
Author: Almar ([[:User:Almar|Almar]])
  
 +
== Description ==
 +
 +
This pretty straightforward script will create quite some number of directories under your Assets folder. This is the default structure I use when creating new projects.
 +
It can also serve as an example to create your own "startup script" for defining your own directory structure.
 +
 +
== Usage ==
 +
 +
Create a file "MakeFolders.cs" in the Assets\Editor directory (create it, it does not exist by default) and paste the code below. A new item will appear at the "Assets" menu.
 +
This code has not been tested at the Mac version of Unity.
 +
 +
== Code ==
 +
 +
<csharp>
 +
using UnityEngine;
 +
using UnityEditor;
 +
using System.Collections;
 +
using System.IO;
 +
 +
/// Store this code as "MakeFolders.cs" in the Assets\Editor directory (create it, if it does not exist)
 +
/// Creates a number of directories for storage of various content types.
 +
/// Modify as you see fit.
 +
/// Directories are created in the Assets dir.
 +
/// Not tested on a Mac.
 +
 +
 +
public class MakeFolders : ScriptableObject
 +
{
 +
 +
    [MenuItem ( "Assets/Make Project Folders" )]
 +
    static void MenuMakeFolders()
 +
    {
 +
CreateFolders();
 +
}
 +
 +
static void CreateFolders()
 +
{
 +
string f = Application.dataPath + "/";
 +
 +
Directory.CreateDirectory(f + "Meshes");
 +
Directory.CreateDirectory(f + "Fonts");
 +
Directory.CreateDirectory(f + "Plugins");
 +
Directory.CreateDirectory(f + "Textures");
 +
Directory.CreateDirectory(f + "Materials");
 +
Directory.CreateDirectory(f + "Physics");
 +
Directory.CreateDirectory(f + "Resources");
 +
Directory.CreateDirectory(f + "Scenes");
 +
Directory.CreateDirectory(f + "Music");
 +
Directory.CreateDirectory(f + "Packages");
 +
Directory.CreateDirectory(f + "Scripts");
 +
Directory.CreateDirectory(f + "Shaders");
 +
Directory.CreateDirectory(f + "Sounds");
 +
 +
Debug.Log("Created directories");
 +
}
 +
}
 +
</csharp>

Revision as of 19:17, 19 October 2009

Author: Almar (Almar)

Description

This pretty straightforward script will create quite some number of directories under your Assets folder. This is the default structure I use when creating new projects. It can also serve as an example to create your own "startup script" for defining your own directory structure.

Usage

Create a file "MakeFolders.cs" in the Assets\Editor directory (create it, it does not exist by default) and paste the code below. A new item will appear at the "Assets" menu. This code has not been tested at the Mac version of Unity.

Code

<csharp> using UnityEngine; using UnityEditor; using System.Collections; using System.IO;

/// Store this code as "MakeFolders.cs" in the Assets\Editor directory (create it, if it does not exist) /// Creates a number of directories for storage of various content types. /// Modify as you see fit. /// Directories are created in the Assets dir. /// Not tested on a Mac.


public class MakeFolders : ScriptableObject {

   [MenuItem ( "Assets/Make Project Folders" )]
   static void MenuMakeFolders()
   {

CreateFolders(); }

static void CreateFolders() { string f = Application.dataPath + "/";

Directory.CreateDirectory(f + "Meshes"); Directory.CreateDirectory(f + "Fonts"); Directory.CreateDirectory(f + "Plugins"); Directory.CreateDirectory(f + "Textures"); Directory.CreateDirectory(f + "Materials"); Directory.CreateDirectory(f + "Physics"); Directory.CreateDirectory(f + "Resources"); Directory.CreateDirectory(f + "Scenes"); Directory.CreateDirectory(f + "Music"); Directory.CreateDirectory(f + "Packages"); Directory.CreateDirectory(f + "Scripts"); Directory.CreateDirectory(f + "Shaders"); Directory.CreateDirectory(f + "Sounds");

Debug.Log("Created directories"); } } </csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox