Skip to content

Commit

Permalink
Add tool and temp folder (#1120)
Browse files Browse the repository at this point in the history
* add tool and temp folder

* add a tool, get name of all scripts

* generate names in alphanumeric order

* add assembly, rename folder devtools in editortools, add namespace
  • Loading branch information
stilnat authored Mar 20, 2023
1 parent cb88c81 commit 7f2c2a0
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,7 @@ crashlytics-build.properties
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*

# Files generated by SS3D tools that should not be commited.
/[Aa]ssets/Temp/*

\.idea/
8 changes: 8 additions & 0 deletions Assets/Scripts/EditorTools.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/Scripts/EditorTools/EditorTools.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "EditorTools"
}
7 changes: 7 additions & 0 deletions Assets/Scripts/EditorTools/EditorTools.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions Assets/Scripts/EditorTools/GetNameOfAllScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

using UnityEngine;
using UnityEditor;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace EditorTools
{
class GetNameOfAllScript : EditorWindow
{
private const string filePath = "Assets/Temp/ScriptsNames.txt";
private const string scriptsPath = "Assets/Scripts/SS3D";
private static List<string> scriptNames;

[MenuItem("Tools/SS3D/Get name of all scripts")]
public static void ShowWindow()
{
GetWindow<GetNameOfAllScript>("Get name of all scripts");
}
private void OnGUI()
{
GUILayout.Label("Generate name of all SS3D scripts,\n write them in file located at " + filePath + ".");
if (GUILayout.Button("Generate names"))
{
scriptNames = new List<string>();
DirectoryInfo rootDir = new DirectoryInfo(scriptsPath);
File.Delete(filePath);
WalkDirectoryTree(rootDir);
scriptNames.Sort((x, y) => string.Compare(x, y));
foreach (string name in scriptNames)
{
File.AppendAllText(filePath, name);
}
scriptNames.Clear();
}
}

static void WalkDirectoryTree(DirectoryInfo root)
{
FileInfo[] files = null;
DirectoryInfo[] subDirs = null;

// First, process all the files directly under this folder
files = root.GetFiles("*.cs");

if (files != null)
{
foreach (FileInfo fi in files)
{
scriptNames.Add(fi.Name + "\n");
}

// Now find all the subdirectories under this directory.
subDirs = root.GetDirectories();

foreach (DirectoryInfo dirInfo in subDirs)
{
// Resursive call for each subdirectory.
WalkDirectoryTree(dirInfo);
}
}
}
}

}
11 changes: 11 additions & 0 deletions Assets/Scripts/EditorTools/GetNameOfAllScript.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Temp.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7f2c2a0

Please sign in to comment.