public void TestMessageBuildSingle_ThrowsNoExceptions(string messageToBuild) { var msgPath = MessageAutoGen.GetMessageClassPath(messageToBuild, m_MessageGenOutputPath); Debug.Log($"Generating code for {messageToBuild}, output should be at {msgPath}"); WarnIfAlreadyExists(msgPath, PathType.File); MessageAutoGen.GenerateSingleMessage(messageToBuild, m_MessageGenOutputPath); AssetDatabase.Refresh(); AssertExists(msgPath, PathType.File); }
public void TestMessageBuildDirectory_ThrowsNoExceptions(string directoryToBuild) { var msgPath = MessageAutoGen.GetMessageClassPath(directoryToBuild, m_MessageGenOutputPath); var msgDirectory = Path.GetDirectoryName(msgPath); Debug.Log($"Generating code in {directoryToBuild}, output should be in {msgDirectory}"); WarnIfAlreadyExists(msgDirectory, PathType.Directory); MessageAutoGen.GenerateDirectoryMessages(directoryToBuild, m_MessageGenOutputPath); AssetDatabase.Refresh(); AssertExists(msgDirectory, PathType.Directory); }
public override void OnImportAsset(AssetImportContext ctx) { string inputPath = Path.Combine(Directory.GetCurrentDirectory(), ctx.assetPath); string outputPath = MessageGenBrowserSettings.Get().outputPath; MessageAutoGen.GenerateSingleMessage(inputPath, outputPath); string builtPath = MessageAutoGen.GetMessageClassPath(inputPath, outputPath); string builtAssetPath = Path.Combine("Assets", MessageGenBrowserSettings.ToRelativePath(builtPath)); AssetDatabase.ImportAsset(builtAssetPath); Object messageClass = AssetDatabase.LoadAssetAtPath(builtAssetPath, typeof(MonoScript)); if (messageClass != null) { ctx.AddObjectToAsset("messageClass", messageClass); } }
CachedEntryStatus GetFileStatus(string path) { switch (Path.GetExtension(path)) { case ".msg": string builtMessagePath = MessageAutoGen.GetMessageClassPath(path, MessageGenBrowserSettings.Get().outputPath); return(File.Exists(builtMessagePath) ? CachedEntryStatus.BuiltMsgFile : CachedEntryStatus.UnbuiltMsgFile); case ".srv": string[] builtServicePaths = ServiceAutoGen.GetServiceClassPaths(path, MessageGenBrowserSettings.Get().outputPath); return(builtServicePaths.All(file => File.Exists(file)) ? CachedEntryStatus.BuiltSrvFile : CachedEntryStatus.UnbuiltSrvFile); case ".action": string[] builtActionPaths = ActionAutoGen.GetActionClassPaths(path, MessageGenBrowserSettings.Get().outputPath); return(builtActionPaths.All(file => File.Exists(file)) ? CachedEntryStatus.BuiltActionFile : CachedEntryStatus.UnbuiltActionFile); } return(CachedEntryStatus.Ignored); }