Browse Source

Add protobuf editor script

new_protocol
ThePerkinrex 5 years ago
parent
commit
7d2a9acd08
No known key found for this signature in database GPG Key ID: 1F45A7C4BFB41607
  1. 1
      gen-grpc-unity.ps1
  2. 102
      unity/.vscode/settings.json
  3. 2
      unity/Assets/EditorScripts.meta
  4. 102
      unity/Assets/EditorScripts/BuildProtos.cs
  5. 11
      unity/Assets/EditorScripts/BuildProtos.cs.meta
  6. 2
      unity/Assets/Plugins/Google.Protobuf/lib/net45.meta
  7. BIN
      unity/Assets/Plugins/Google.Protobuf/lib/net45/Google.Protobuf.dll
  8. 2
      unity/Assets/Plugins/Google.Protobuf/lib/net45/Google.Protobuf.dll.meta
  9. 0
      unity/Assets/Plugins/Google.Protobuf/lib/net45/Google.Protobuf.xml
  10. 2
      unity/Assets/Plugins/Google.Protobuf/lib/net45/Google.Protobuf.xml.meta
  11. 153
      unity/Assets/Plugins/Google.Protobuf/lib/netstandard2.0/Google.Protobuf.deps.json
  12. 7
      unity/Assets/Plugins/Google.Protobuf/lib/netstandard2.0/Google.Protobuf.deps.json.meta
  13. BIN
      unity/Assets/Plugins/Google.Protobuf/lib/netstandard2.0/Google.Protobuf.dll

1
gen-grpc-unity.ps1

@ -1 +0,0 @@
unity/Packages/Grpc.Tools.2.33.1/tools/windows_x64/protoc.exe -I protobuf --csharp_out=unity/Assets/Scripts/grpc --grpc_out=unity/Assets/Scripts/grpc --plugin=protoc-gen-grpc=unity/Packages/Grpc.Tools.2.33.1/tools/windows_x64/grpc_csharp_plugin.exe $(ls | grep *.proto)

102
unity/.vscode/settings.json

@ -1,56 +1,56 @@
{
"files.exclude":
{
"**/.DS_Store":true,
"**/.git":true,
"**/.gitignore":true,
"**/.gitmodules":true,
"**/*.booproj":true,
"**/*.pidb":true,
"**/*.suo":true,
"**/*.user":true,
"**/*.userprefs":true,
"**/*.unityproj":true,
"**/*.dll":true,
"**/*.exe":true,
"**/*.pdf":true,
"**/*.mid":true,
"**/*.midi":true,
"**/*.wav":true,
"**/*.gif":true,
"**/*.ico":true,
"**/*.jpg":true,
"**/*.jpeg":true,
"**/*.png":true,
"**/*.psd":true,
"**/*.tga":true,
"**/*.tif":true,
"**/*.tiff":true,
"**/*.3ds":true,
"**/*.3DS":true,
"**/*.fbx":true,
"**/*.FBX":true,
"**/*.lxo":true,
"**/*.LXO":true,
"**/*.ma":true,
"**/*.MA":true,
"**/*.obj":true,
"**/*.OBJ":true,
"**/*.asset":true,
"**/*.cubemap":true,
"**/*.flare":true,
"**/*.mat":true,
"**/*.meta":true,
"**/*.prefab":true,
"**/*.unity":true,
"build/":true,
"Build/":true,
"Library/":true,
"library/":true,
"obj/":true,
"Obj/":true,
"ProjectSettings/":true,
"temp/":true,
"Temp/":true
// "**/.DS_Store":true,
// "**/.git":true,
// "**/.gitignore":true,
// "**/.gitmodules":true,
// "**/*.booproj":true,
// "**/*.pidb":true,
// "**/*.suo":true,
// "**/*.user":true,
// "**/*.userprefs":true,
// "**/*.unityproj":true,
// "**/*.dll":true,
// "**/*.exe":true,
// "**/*.pdf":true,
// "**/*.mid":true,
// "**/*.midi":true,
// "**/*.wav":true,
// "**/*.gif":true,
// "**/*.ico":true,
// "**/*.jpg":true,
// "**/*.jpeg":true,
// "**/*.png":true,
// "**/*.psd":true,
// "**/*.tga":true,
// "**/*.tif":true,
// "**/*.tiff":true,
// "**/*.3ds":true,
// "**/*.3DS":true,
// "**/*.fbx":true,
// "**/*.FBX":true,
// "**/*.lxo":true,
// "**/*.LXO":true,
// "**/*.ma":true,
// "**/*.MA":true,
// "**/*.obj":true,
// "**/*.OBJ":true,
// "**/*.asset":true,
// "**/*.cubemap":true,
// "**/*.flare":true,
// "**/*.mat":true,
// "**/*.meta":true,
// "**/*.prefab":true,
// "**/*.unity":true,
// "build/":true,
// "Build/":true,
// "Library/":true,
// "library/":true,
// "obj/":true,
// "Obj/":true,
// "ProjectSettings/":true,
// "temp/":true,
// "Temp/":true
}
}

2
unity/Assets/Plugins/Google.Protobuf/lib/netstandard2.0.meta → unity/Assets/EditorScripts.meta

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: bce749003a0bdadb19f6ed8515954331
guid: 8cfb1604c51a61a269b6e06bedd43ade
folderAsset: yes
DefaultImporter:
externalObjects: {}

102
unity/Assets/EditorScripts/BuildProtos.cs

@ -0,0 +1,102 @@
// C# example.
using UnityEditor;
using UnityEngine;
using System.Runtime.InteropServices;
using System.IO;
using System.Diagnostics;
using System;
public class ScriptBatch
{
[MenuItem("Protobuf/Build C# GRPC connecting code")]
public static void BuildGRPC()
{
string arch = null;
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm || RuntimeInformation.ProcessArchitecture == Architecture.X86)
{
arch = "x86";
}
else
{
arch = "x64";
}
string protoc = null;
string plugin = null;
string basePath = Application.dataPath.Substring(0, Application.dataPath.Length - "/Assets".Length);
string protobufPath = Path.Combine(Application.dataPath.Substring(0, Application.dataPath.Length - "/unity/Assets".Length), "protobuf");
string outDir = Path.Combine(Application.dataPath, "Scripts", "grpc");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
protoc = basePath + "/Packages/Grpc.Tools.2.33.1/tools/linux_" + arch + "/protoc";
plugin = basePath + "/Packages/Grpc.Tools.2.33.1/tools/linux_" + arch + "/grpc_csharp_plugin";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
protoc = basePath + "\\Packages\\Grpc.Tools.2.33.1\\tools\\windows_" + arch + "\\protoc.exe";
plugin = basePath + "\\Packages\\Grpc.Tools.2.33.1\\tools\\windows_" + arch + "\\grpc_csharp_plugin.exe";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
protoc = basePath + "/Packages/Grpc.Tools.2.33.1/tools/macosx_" + arch + "/protoc";
plugin = basePath + "/Packages/Grpc.Tools.2.33.1/tools/macosx_" + arch + "/grpc_csharp_plugin";
}
UnityEngine.Debug.Log(protoc);
UnityEngine.Debug.Log(plugin);
// // For the example
// const string ex1 = "C:\\";
// const string ex2 = "C:\\Dir";
// // Use ProcessStartInfo class
try{
var protoFiles = Directory.EnumerateFiles(protobufPath, "*.proto");
foreach (string currentFile in protoFiles)
{
compile_file(protoc, plugin, protobufPath, outDir, currentFile);
}
} catch (Exception e) {
UnityEngine.Debug.LogException(e);
}
// try
// {
// // Start the process with the info we specified.
// // Call WaitForExit and then the using statement will close.
// using (Process exeProcess = Process.Start(startInfo))
// {
// exeProcess.WaitForExit();
// }
// }
// catch
// {
// // Log error.
// }
}
public static void compile_file(string protoc, string plugin, string protobufPath, string outDir, string file) {
// -I protobuf --csharp_out=unity/Assets/Scripts/grpc --grpc_out=unity/Assets/Scripts/grpc --plugin=protoc-gen-grpc=unity/Packages/Grpc.Tools.2.33.1/tools/linux_x64/grpc_csharp_plugin file
Process myProcess = new Process();
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.FileName = protoc;
// string path = "C:\\Users\\Brian\\Desktop\\testFile.bat";
myProcess.StartInfo.Arguments = $"-I \"{protobufPath}\" --csharp_out=\"{outDir}\" --grpc_out=\"{outDir}\" --plugin=protoc-gen-grpc=\"{plugin}\" \"{file}\"";
myProcess.EnableRaisingEvents = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.Start();
myProcess.WaitForExit();
if (myProcess.ExitCode != 0) {
throw new IOException($"Protoc error: {myProcess.StandardError.ReadToEnd()}");
}else{
UnityEngine.Debug.Log($"Compiled {file}");
}
}
}

11
unity/Assets/EditorScripts/BuildProtos.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d503170ae4972ff3db5f76af29a9d5d0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

2
unity/Assets/System.Memory.4.5.2.meta → unity/Assets/Plugins/Google.Protobuf/lib/net45.meta

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4c60b03ea1edf5b2cb00c10be02d2695
guid: 9c89fa53a27731afa83aa08718530381
folderAsset: yes
DefaultImporter:
externalObjects: {}

BIN
unity/Assets/Plugins/Google.Protobuf/lib/net45/Google.Protobuf.dll

Binary file not shown.

2
unity/Assets/Plugins/Google.Protobuf/lib/netstandard2.0/Google.Protobuf.dll.meta → unity/Assets/Plugins/Google.Protobuf/lib/net45/Google.Protobuf.dll.meta

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: adf15f0bfc98d0068b4c00bc8d2ff4a7
guid: e9f801151b80bd03399e2ed139b47e48
PluginImporter:
externalObjects: {}
serializedVersion: 2

0
unity/Assets/Plugins/Google.Protobuf/lib/netstandard2.0/Google.Protobuf.xml → unity/Assets/Plugins/Google.Protobuf/lib/net45/Google.Protobuf.xml

2
unity/Assets/Plugins/Google.Protobuf/lib/netstandard2.0/Google.Protobuf.xml.meta → unity/Assets/Plugins/Google.Protobuf/lib/net45/Google.Protobuf.xml.meta

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4893c5261f7831e6f8faff3aa905326a
guid: 56ac33eabace70554b7cdf28394f660c
TextScriptImporter:
externalObjects: {}
userData:

153
unity/Assets/Plugins/Google.Protobuf/lib/netstandard2.0/Google.Protobuf.deps.json

@ -1,153 +0,0 @@
{
"runtimeTarget": {
"name": ".NETStandard,Version=v2.0/",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETStandard,Version=v2.0": {},
".NETStandard,Version=v2.0/": {
"Google.Protobuf/3.13.0": {
"dependencies": {
"Microsoft.NETFramework.ReferenceAssemblies": "1.0.0",
"Microsoft.SourceLink.GitHub": "1.0.0",
"NETStandard.Library": "2.0.3",
"System.Memory": "4.5.3",
"System.Runtime.CompilerServices.Unsafe": "4.5.2"
},
"runtime": {
"Google.Protobuf.dll": {}
}
},
"Microsoft.Build.Tasks.Git/1.0.0": {},
"Microsoft.NETCore.Platforms/1.1.0": {},
"Microsoft.NETFramework.ReferenceAssemblies/1.0.0": {},
"Microsoft.SourceLink.Common/1.0.0": {},
"Microsoft.SourceLink.GitHub/1.0.0": {
"dependencies": {
"Microsoft.Build.Tasks.Git": "1.0.0",
"Microsoft.SourceLink.Common": "1.0.0"
}
},
"NETStandard.Library/2.0.3": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
"System.Buffers/4.4.0": {
"runtime": {
"lib/netstandard2.0/System.Buffers.dll": {
"assemblyVersion": "4.0.2.0",
"fileVersion": "4.6.25519.3"
}
}
},
"System.Memory/4.5.3": {
"dependencies": {
"System.Buffers": "4.4.0",
"System.Numerics.Vectors": "4.4.0",
"System.Runtime.CompilerServices.Unsafe": "4.5.2"
},
"runtime": {
"lib/netstandard2.0/System.Memory.dll": {
"assemblyVersion": "4.0.1.1",
"fileVersion": "4.6.27617.2"
}
}
},
"System.Numerics.Vectors/4.4.0": {
"runtime": {
"lib/netstandard2.0/System.Numerics.Vectors.dll": {
"assemblyVersion": "4.1.3.0",
"fileVersion": "4.6.25519.3"
}
}
},
"System.Runtime.CompilerServices.Unsafe/4.5.2": {
"runtime": {
"lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll": {
"assemblyVersion": "4.0.4.1",
"fileVersion": "4.0.0.0"
}
}
}
}
},
"libraries": {
"Google.Protobuf/3.13.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.Build.Tasks.Git/1.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-z2fpmmt+1Jfl+ZnBki9nSP08S1/tbEOxFdsK1rSR+LBehIJz1Xv9/6qOOoGNqlwnAGGVGis1Oj6S8Kt9COEYlQ==",
"path": "microsoft.build.tasks.git/1.0.0",
"hashPath": "microsoft.build.tasks.git.1.0.0.nupkg.sha512"
},
"Microsoft.NETCore.Platforms/1.1.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
"path": "microsoft.netcore.platforms/1.1.0",
"hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
},
"Microsoft.NETFramework.ReferenceAssemblies/1.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-7D2TMufjGiowmt0E941kVoTIS+GTNzaPopuzM1/1LSaJAdJdBrVP0SkZW7AgDd0a2U1DjsIeaKG1wxGVBNLDMw==",
"path": "microsoft.netframework.referenceassemblies/1.0.0",
"hashPath": "microsoft.netframework.referenceassemblies.1.0.0.nupkg.sha512"
},
"Microsoft.SourceLink.Common/1.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-G8DuQY8/DK5NN+3jm5wcMcd9QYD90UV7MiLmdljSJixi3U/vNaeBKmmXUqI4DJCOeWizIUEh4ALhSt58mR+5eg==",
"path": "microsoft.sourcelink.common/1.0.0",
"hashPath": "microsoft.sourcelink.common.1.0.0.nupkg.sha512"
},
"Microsoft.SourceLink.GitHub/1.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-aZyGyGg2nFSxix+xMkPmlmZSsnGQ3w+mIG23LTxJZHN+GPwTQ5FpPgDo7RMOq+Kcf5D4hFWfXkGhoGstawX13Q==",
"path": "microsoft.sourcelink.github/1.0.0",
"hashPath": "microsoft.sourcelink.github.1.0.0.nupkg.sha512"
},
"NETStandard.Library/2.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"path": "netstandard.library/2.0.3",
"hashPath": "netstandard.library.2.0.3.nupkg.sha512"
},
"System.Buffers/4.4.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-AwarXzzoDwX6BgrhjoJsk6tUezZEozOT5Y9QKF94Gl4JK91I4PIIBkBco9068Y9/Dra8Dkbie99kXB8+1BaYKw==",
"path": "system.buffers/4.4.0",
"hashPath": "system.buffers.4.4.0.nupkg.sha512"
},
"System.Memory/4.5.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-3oDzvc/zzetpTKWMShs1AADwZjQ/36HnsufHRPcOjyRAAMLDlu2iD33MBI2opxnezcVUtXyqDXXjoFMOU9c7SA==",
"path": "system.memory/4.5.3",
"hashPath": "system.memory.4.5.3.nupkg.sha512"
},
"System.Numerics.Vectors/4.4.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-UiLzLW+Lw6HLed1Hcg+8jSRttrbuXv7DANVj0DkL9g6EnnzbL75EB7EWsw5uRbhxd/4YdG8li5XizGWepmG3PQ==",
"path": "system.numerics.vectors/4.4.0",
"hashPath": "system.numerics.vectors.4.4.0.nupkg.sha512"
},
"System.Runtime.CompilerServices.Unsafe/4.5.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-wprSFgext8cwqymChhrBLu62LMg/1u92bU+VOwyfBimSPVFXtsNqEWC92Pf9ofzJFlk4IHmJA75EDJn1b2goAQ==",
"path": "system.runtime.compilerservices.unsafe/4.5.2",
"hashPath": "system.runtime.compilerservices.unsafe.4.5.2.nupkg.sha512"
}
}
}

7
unity/Assets/Plugins/Google.Protobuf/lib/netstandard2.0/Google.Protobuf.deps.json.meta

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: c9978bb674bbf9da1bf72d1b498e5038
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
unity/Assets/Plugins/Google.Protobuf/lib/netstandard2.0/Google.Protobuf.dll

Binary file not shown.
Loading…
Cancel
Save