Last active
September 26, 2024 09:02
-
-
Save Namek/ecafa24a6ae3d730baf1 to your computer and use it in GitHub Desktop.
Revisions
-
Namek revised this gist
Sep 23, 2014 . 2 changed files with 80 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ //This class is auto-generated, do not modify (use Tools/TagsLayersEnumBuilder) public abstract class Layers { public const string Default = "Default"; public const string TransparentFX = "TransparentFX"; public const string IgnoreRaycast = "Ignore Raycast"; public const string Water = "Water"; public const string UI = "UI"; public const string Camera = "Camera"; public const string Characters = "Characters"; public const string Floor = "Floor"; public const string Sprites = "Sprites"; public const string Terrain = "Terrain"; public const string Squads = "Squads"; public const string Selectable = "Selectable"; public const string Obstacles = "Obstacles"; public const int DefaultMask = 1; public const int TransparentFXMask = 1 << 1; public const int IgnoreRaycastMask = 1 << 2; public const int WaterMask = 1 << 4; public const int UIMask = 1 << 5; public const int CameraMask = 1 << 8; public const int CharactersMask = 1 << 9; public const int FloorMask = 1 << 10; public const int SpritesMask = 1 << 11; public const int TerrainMask = 1 << 12; public const int SquadsMask = 1 << 13; public const int SelectableMask = 1 << 14; public const int ObstaclesMask = 1 << 15; public const int DefaultNumber = 0; public const int TransparentFXNumber = 1; public const int IgnoreRaycastNumber = 2; public const int WaterNumber = 4; public const int UINumber = 5; public const int CameraNumber = 8; public const int CharactersNumber = 9; public const int FloorNumber = 10; public const int SpritesNumber = 11; public const int TerrainNumber = 12; public const int SquadsNumber = 13; public const int SelectableNumber = 14; public const int ObstaclesNumber = 15; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ //This class is auto-generated, do not modify (TagsLayersEnumBuilder.cs) public abstract class Tags { public const string AIOrder = "AIOrder"; public const string Camera2D = "Camera2D"; public const string CameraMan = "CameraMan"; public const string Dangerous = "Dangerous"; public const string Debug = "Debug"; public const string EditorOnly = "EditorOnly"; public const string EnemyStatsBar = "EnemyStatsBar"; public const string Finish = "Finish"; public const string Fire = "Fire"; public const string Formation = "Formation"; public const string GameController = "GameController"; public const string Ground = "Ground"; public const string HUDPanel = "HUDPanel"; public const string Item = "Item"; public const string MainCamera = "MainCamera"; public const string MatchTimerLabel = "MatchTimerLabel"; public const string Obstacles = "Obstacles"; public const string Player = "Player"; public const string PlayerSkillPointsBar = "PlayerSkillPointsBar"; public const string PlayerSpawningPoint = "PlayerSpawningPoint"; public const string PlayerStatsBar = "PlayerStatsBar"; public const string RangedAttack = "RangedAttack"; public const string Respawn = "Respawn"; public const string SelectedSquad = "SelectedSquad"; public const string Skill = "Skill"; public const string SkillButton = "SkillButton"; public const string SkillLabel = "SkillLabel"; public const string Smelly = "Smelly"; public const string SquadPosition = "SquadPosition"; public const string SquadSelector = "SquadSelector"; public const string SquadSpawningPoint = "SquadSpawningPoint"; public const string Unit = "Unit"; public const string Untagged = "Untagged"; } -
Namek created this gist
Sep 23, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,89 @@ #if UNITY_EDITOR using UnityEngine; using System.Collections; using UnityEditor; using System; using System.IO; using System.Text; public class TagsLayersEnumBuilder : EditorWindow { [MenuItem("Edit/Rebuild Tags And Layers Enums")] static void RebuildTagsAndLayersEnums() { var enumsPath = Application.dataPath + "/Code/Enums/"; rebuildTagsFile(enumsPath + "Tags.cs"); rebuildLayersFile(enumsPath + "Layers.cs"); AssetDatabase.ImportAsset(enumsPath + "Tags.cs", ImportAssetOptions.ForceUpdate); AssetDatabase.ImportAsset(enumsPath + "Layers.cs", ImportAssetOptions.ForceUpdate); } static void rebuildTagsFile(string filePath) { StringBuilder sb = new StringBuilder(); sb.Append("//This class is auto-generated, do not modify (TagsLayersEnumBuilder.cs)\n"); sb.Append("public abstract class Tags {\n"); var srcArr = UnityEditorInternal.InternalEditorUtility.tags; var tags = new String[srcArr.Length]; Array.Copy(srcArr, tags, tags.Length); Array.Sort(tags, StringComparer.InvariantCultureIgnoreCase); for (int i = 0, n = tags.Length; i < n; ++i) { string tagName = tags[i]; sb.Append("\tpublic const string " + tagName + " = \"" + tagName + "\";\n"); } sb.Append("}\n"); #if !UNITY_WEBPLAYER File.WriteAllText(filePath, sb.ToString()); #endif } static void rebuildLayersFile(string filePath) { StringBuilder sb = new StringBuilder(); sb.Append("//This class is auto-generated, do not modify (use Tools/TagsLayersEnumBuilder)\n"); sb.Append("public abstract class Layers {\n"); var layers = UnityEditorInternal.InternalEditorUtility.layers; for (int i = 0, n = layers.Length; i < n; ++i) { string layerName = layers[i]; sb.Append("\tpublic const string " + GetVariableName(layerName) + " = \"" + layerName + "\";\n"); } sb.Append("\n"); for (int i = 0, n = layers.Length; i < n; ++i) { string layerName = layers[i]; int layerNumber = LayerMask.NameToLayer(layerName); string layerMask = layerNumber == 0 ? "1" : ("1 << " + layerNumber); sb.Append("\tpublic const int " + GetVariableName(layerName) + "Mask" + " = " + layerMask + ";\n"); } sb.Append("\n"); for (int i = 0, n = layers.Length; i < n; ++i) { string layerName = layers[i]; int layerNumber = LayerMask.NameToLayer(layerName); sb.Append("\tpublic const int " + GetVariableName(layerName) + "Number" + " = " + layerNumber + ";\n"); } sb.Append("}\n"); #if !UNITY_WEBPLAYER File.WriteAllText(filePath, sb.ToString()); #endif } private static string GetVariableName(string str) { return str.Replace(" ", ""); } } #endif