Skip to content

Commit

Permalink
Merge pull request #165 from Cysharp/solution_file_processor
Browse files Browse the repository at this point in the history
solution file processor sample
  • Loading branch information
neuecc committed Jul 9, 2019
2 parents 9208fc2 + d4636f3 commit 43aba25
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 24 deletions.
@@ -0,0 +1,33 @@
using System;
using UnityEditor;

public class SolutionFileProcessor : AssetPostprocessor
{
const string ProjectTypeGuidCsharp = "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
const string ProjectTypeGuidConsoleApp = "9A19103F-16F7-4668-BE54-9A1E7A4F7556";

private static string OnGeneratedSlnSolution(string path, string content)
{
// Automatically include ProjectFiles into SolutionFile

var newContent = AddProject(
content: content,
ProjectTypeGuidConsoleApp,
projectGuid: "053476FC-B8B2-4A14-AED2-3733DFD5DFC3",
projectName: "ChatApp.Server",
projectPath: "..\\ChatApp.Server\\ChatApp.Server.csproj");


return newContent;
}

private static string AddProject(string content, string projectTypeGuid, string projectGuid, string projectName, string projectPath)
{
var add = $"Project(\"{projectTypeGuid}\") = \"{projectName}\", \"{projectPath}\", \"{projectGuid}\",\"{Environment.NewLine}EndProject";

var newContent = content.Replace($"EndProject{Environment.NewLine}Global",
$"EndProject{Environment.NewLine}{add}{Environment.NewLine}Global");

return newContent;
}
}

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

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 9 additions & 0 deletions samples/README.md
Expand Up @@ -112,6 +112,15 @@ private async void RegisterDisconnectEvent(IChatHub streamingClient)
}
```

## Dynamic coexistence of Server and Unity project files.
The Server project is removed every time Unity regenerates a solution file.
With a class that extends `AssetPostprocessor` and a method of `OnGeneratedSlnSolution`
An arbitrary project file is automatically included when a solution file is generated.
This ensures that the Server and Unity project files co-exist.

The Sample implementation is as follows:.
https://github.com/Cysharp/MagicOnion/blob/master/samples/ChatApp/ChatApp.Unity/Assets/Editor/SolutionFileProcessor.cs


## How to run the app
1. Launch `ChatApp.Server` from VisualStudio.
Expand Down

0 comments on commit 43aba25

Please sign in to comment.