Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
Prevent worker builds with compiler errors in Unity Editor (#1425)
Browse files Browse the repository at this point in the history
* Add CHANGELOG entry

* Disable MenuBuild with editor compile errors

* Fix codegen for Unity worker menu build

* Generate one validation function for menu build
  • Loading branch information
Sean Parker authored Jul 21, 2020
1 parent e935704 commit dd61c08
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

- Added support for multiple annotations in Code Writer API. [#1427](https://github.com/spatialos/gdk-for-unity/pull/1427)
- Prevent building workers with Unity Editor compile errors. [#1425](https://github.com/spatialos/gdk-for-unity/pull/1425)

## `0.3.8` - 2020-07-20

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public static CodeWriter Generate(List<string> workerTypes)
return workerTypes.Select(workerType => $@"""{workerType}""");
});
var allMenuOptionValidators = buildWorkerMenu.Annotate($@"MenuItem(EditorConfig.ParentMenu + ""/"" + LocalMenu + ""/All workers"", true, EditorConfig.MenuOffset + {workerTypes.Count})")
.Annotate($@"MenuItem(EditorConfig.ParentMenu + ""/"" + CloudMenu + ""/All workers"", true, EditorConfig.MenuOffset + {workerTypes.Count})");

for (var i = 0; i < workerTypes.Count; i++)
{
var workerType = workerTypes[i];
Expand All @@ -50,8 +53,16 @@ public static CodeWriter Generate(List<string> workerTypes)
{
$@"MenuBuildCloud(new[] {{ {workerTypeString} }});"
});

allMenuOptionValidators.Annotate($@"MenuItem(EditorConfig.ParentMenu + ""/"" + LocalMenu + ""/{workerType}"", true, EditorConfig.MenuOffset + {i})")
.Annotate($@"MenuItem(EditorConfig.ParentMenu + ""/"" + CloudMenu + ""/{workerType}"", true, EditorConfig.MenuOffset + {i})");
}

allMenuOptionValidators.Method("public static bool ValidateEditorCompile()", () => new[]
{
"return !EditorUtility.scriptCompilationFailed;"
});

buildWorkerMenu.Annotate($@"MenuItem(EditorConfig.ParentMenu + ""/"" + LocalMenu + ""/All workers"", false, EditorConfig.MenuOffset + {workerTypes.Count})")
.Method("public static void BuildLocalAll()", () => new[]
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Improbable.Gdk.BuildSystem.Configuration;
using Improbable.Gdk.Core;
using Improbable.Gdk.Tools;
Expand Down

0 comments on commit dd61c08

Please sign in to comment.