Skip to content

Instantly share code, notes, and snippets.

@twobob
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twobob/84431c58ba65282f450f to your computer and use it in GitHub Desktop.
Save twobob/84431c58ba65282f450f to your computer and use it in GitHub Desktop.
Add LOD suffixes to selected files
using UnityEngine;
using UnityEditor;
using System.Collections;
public class AddSuffixLOD : MonoBehaviour {
[MenuItem("Tools/AddSuffix/_LOD0")]
static void AddSuffix0()
{ // Suffixes _LOD0 to the name
AddSuffixViaString("_LOD0");
}
[MenuItem("Tools/AddSuffix/_LOD1")]
static void AddSuffix1()
{ // Suffixes _LOD1 to the name
AddSuffixViaString("_LOD1");
}
[MenuItem("Tools/AddSuffix/_LOD2")]
static void AddSuffix2()
{ // Suffixes _LOD2 to the name
AddSuffixViaString("_LOD2");
}
[MenuItem("Tools/AddSuffix/_LOD3")]
static void AddSuffix3()
{ // Suffixes _LOD3 to the name
AddSuffixViaString("_LOD3");
}
[MenuItem("Tools/AddSuffix/_LOD4")]
static void AddSuffix4()
{ // Suffixes _LOD4 to the name
AddSuffixViaString("_LOD4");
}
[MenuItem("Tools/AddSuffix/_LOD5")]
static void AddSuffix5()
{ // Suffixes _LOD5 to the name
AddSuffixViaString("_LOD5");
}
[MenuItem("Tools/AddSuffix/Strip_Suffix")]
static void StripSuffix()
{ // STRIP suffix from the name
RemoveSuffix();
}
private static void RemoveSuffix()
{
foreach (GameObject go in Selection.gameObjects)
{
go.name = go.name.Remove(go.name.IndexOf("_LOD"));
}
}
private static void AddSuffixViaString(string suffix)
{
foreach (GameObject go in Selection.gameObjects)
{
go.name = go.name + suffix;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment