-
-
Save rotorz/76294eb6ada6d64949c5 to your computer and use it in GitHub Desktop.
Demonstration of generation of localized MenuItem's
This file contains 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 characters
#=======================================================================================# | |
# Unity Integration | |
#---------------------------------------------------------------------------------------# | |
# Menu Items | |
Integration.CreateTileSystem = Create Tile System... | |
Integration.CreateOther.RotorzTileSystem = Rotorz Tile System... | |
Integration.Create.BrushOrTileset = Rotorz Brush or Tileset... | |
Integration.ToolMenu.UseAsPrefabOffset = Use as Prefab Offset | |
Integration.ToolMenu.ReplaceByBrush = Replace by Brush... | |
Integration.ToolMenu.BuildScene = Build Scene... | |
Integration.ToolMenu.RescanBrushes = Rescan Brushes | |
Integration.ToolMenu.EditorWindows = Editor Windows | |
Integration.ToolMenu.EditorWindows.Designer = Designer | |
Integration.ToolMenu.EditorWindows.Scene = Scene | |
Integration.ToolMenu.EditorWindows.Brushes = Brushes | |
Integration.ToolMenu.OnlineResources = Online Resources | |
Integration.ToolMenu.OnlineResources.HomePage = Home Page | |
Integration.ToolMenu.OnlineResources.UserGuide = User Guide | |
Integration.ToolMenu.OnlineResources.ApiReference = API Reference | |
Integration.ToolMenu.OnlineResources.ReleaseNotes = Release Notes | |
Integration.ToolMenu.OnlineResources.YouTubeChannel = YouTube Channel | |
Integration.ToolMenu.OnlineResources.TwitterProfile = Twitter Profile | |
Integration.ToolMenu.OnlineResources.FacebookProfile = Facebook Profile |
This file contains 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 characters
// Copyright (c) Rotorz Limited. All rights reserved. | |
using Rotorz.Tile.Editor; | |
using Rotorz.Tile.Editor.Internal; | |
using UnityEditor; | |
/// <summary> | |
/// Integrates Rotorz Tile System into the Unity user interface. | |
/// </summary> | |
static class RtsUnityIntegration { | |
#region RTS: Tools - Menu Items Test | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Create Tile System...", false, 0)] | |
[MenuItem("GameObject/Create Other/Rotorz Tile System...")] | |
static void Menu_RTS_CreateTileSystem() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Rotorz Brush or Tileset...", false, 0)] | |
[MenuItem("Assets/Create/Rotorz Brush or Tileset...")] | |
static void Menu_RTS_Brushes_CreateBrushOrTileset() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Use as Prefab Offset", false, 100)] | |
static void Menu_RTS_UseAsPrefabOffset() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Use as Prefab Offset", true)] | |
static bool Menu_RTS_UseAsPrefabOffset_Validate() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Replace by Brush...", false, 100)] | |
static void Menu_RTS_Tools_ReplaceByBrush() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Build Scene...", false, 100)] | |
static void Menu_RTS_Tools_BuildScene() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Rescan Brushes", false, 200)] | |
static void Menu_RTS_Brushes_RescanBrushes() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Editor Windows/Designer", false, 5000)] | |
static void Menu_RTS_BrushDesigner() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Editor Windows/Scene", false, 5000)] | |
static void Menu_RTS_EditorWindows_Scene() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Editor Windows/Brushes", false, 5000)] | |
static void Menu_RTS_EditorWindows_Brushes() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Online Resources/Home Page", false, 5000)] | |
static void Menu_RTS_OnlineResources_HomePage() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Online Resources/User Guide", false, 5100)] | |
static void Menu_RTS_OnlineResources_UserGuide() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Online Resources/API Reference", false, 5100)] | |
static void Menu_RTS_OnlineResources_API() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Online Resources/Release Notes", false, 5100)] | |
static void Menu_RTS_OnlineResources_ReleaseNotes() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Online Resources/YouTube Channel", false, 5200)] | |
static void Menu_RTS_OnlineResources_YouTubeChannel() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Online Resources/Twitter Profile", false, 5200)] | |
static void Menu_RTS_OnlineResources_TwitterProfile() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/Online Resources/Facebook Profile", false, 5200)] | |
static void Menu_RTS_OnlineResources_FacebookProfile() { | |
} | |
#endregion | |
} |
This file contains 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 characters
// Copyright (c) Rotorz Limited. All rights reserved. | |
using Rotorz.Tile.Editor; | |
using Rotorz.Tile.Editor.Internal; | |
using UnityEditor; | |
/// <summary> | |
/// Integrates Rotorz Tile System into the Unity user interface. | |
/// </summary> | |
static class RtsUnityIntegration { | |
#region RTS: Tools - Menu Items Test | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.CreateTileSystem }}", false, 0)] | |
[MenuItem("GameObject/Create Other/{{ Integration.CreateOther.RotorzTileSystem }}")] | |
static void Menu_RTS_CreateTileSystem() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.Create.BrushOrTileset }}", false, 0)] | |
[MenuItem("Assets/Create/{{ Integration.Create.BrushOrTileset }}")] | |
static void Menu_RTS_Brushes_CreateBrushOrTileset() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.UseAsPrefabOffset }}", false, 100)] | |
static void Menu_RTS_UseAsPrefabOffset() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.UseAsPrefabOffset }}", true)] | |
static bool Menu_RTS_UseAsPrefabOffset_Validate() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.ReplaceByBrush }}", false, 100)] | |
static void Menu_RTS_Tools_ReplaceByBrush() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.BuildScene }}", false, 100)] | |
static void Menu_RTS_Tools_BuildScene() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.RescanBrushes }}", false, 200)] | |
static void Menu_RTS_Brushes_RescanBrushes() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.EditorWindows }}/{{ Integration.ToolMenu.EditorWindows.Designer }}", false, 5000)] | |
static void Menu_RTS_BrushDesigner() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.EditorWindows }}/{{ Integration.ToolMenu.EditorWindows.Scene }}", false, 5000)] | |
static void Menu_RTS_EditorWindows_Scene() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.EditorWindows }}/{{ Integration.ToolMenu.EditorWindows.Brushes }}", false, 5000)] | |
static void Menu_RTS_EditorWindows_Brushes() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.OnlineResources }}/{{ Integration.ToolMenu.OnlineResources.HomePage }}", false, 5000)] | |
static void Menu_RTS_OnlineResources_HomePage() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.OnlineResources }}/{{ Integration.ToolMenu.OnlineResources.UserGuide }}", false, 5100)] | |
static void Menu_RTS_OnlineResources_UserGuide() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.OnlineResources }}/{{ Integration.ToolMenu.OnlineResources.ApiReference }}", false, 5100)] | |
static void Menu_RTS_OnlineResources_API() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.OnlineResources }}/{{ Integration.ToolMenu.OnlineResources.ReleaseNotes }}", false, 5100)] | |
static void Menu_RTS_OnlineResources_ReleaseNotes() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.OnlineResources }}/{{ Integration.ToolMenu.OnlineResources.YouTubeChannel }}", false, 5200)] | |
static void Menu_RTS_OnlineResources_YouTubeChannel() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.OnlineResources }}/{{ Integration.ToolMenu.OnlineResources.TwitterProfile }}", false, 5200)] | |
static void Menu_RTS_OnlineResources_TwitterProfile() { | |
} | |
[MenuItem("CONTEXT/_RTS_TOOLS_/{{ Integration.ToolMenu.OnlineResources }}/{{ Integration.ToolMenu.OnlineResources.FacebookProfile }}", false, 5200)] | |
static void Menu_RTS_OnlineResources_FacebookProfile() { | |
} | |
#endregion | |
} |
This file contains 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 characters
// Copyright (c) Rotorz Limited. All rights reserved. | |
using Rotorz.Tile.Editor.Localization; | |
using System.IO; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using UnityEditor; | |
static class UnityIntegrationGenerator { | |
[MenuItem("Window/Test Generator")] | |
static void TestGenerator() { | |
string templatePath = Path.Combine(Directory.GetCurrentDirectory(), "Assets/Rotorz/Tile System/Editor/UnityIntegration.cs.txt"); | |
string template = File.ReadAllText(templatePath, Encoding.UTF8); | |
// Parse localization strings in template: | |
template = Regex.Replace(template, @"\{\{\s*([^\}]+)\s*\}\}", match => _.Text(match.Groups[1].Value.Trim())); | |
string outputPath = Path.Combine(Directory.GetCurrentDirectory(), "Assets/Rotorz/Tile System/Editor/UnityIntegration.cs"); | |
File.WriteAllText(outputPath, template, Encoding.UTF8); | |
AssetDatabase.Refresh(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment