Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement new async session api #102

Merged
merged 4 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
root = true

[*]
insert_final_newline = true
indent_style = tab
indent_size = 4
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: greut/eclint-action@v0
- uses: jidicula/clang-format-action@v4.11.0
with: { clang-format-version: "19" }
19 changes: 17 additions & 2 deletions Editor/EcsactBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public static void Build(Options options) {
};

proc.OutputDataReceived += (_, ev) => {
var line = ev.Data;
try {
var line = ev.Data;
if(!string.IsNullOrWhiteSpace(line)) {
var baseMessage = JsonUtility.FromJson<MessageBase>(line);
switch(baseMessage.type) {
Expand Down Expand Up @@ -241,6 +241,9 @@ public static void Build(Options options) {
}
}
} catch(System.Exception err) {
UnityEngine.Debug.LogError(
$"Exception occured while processing this line: {line}"
);
UnityEngine.Debug.LogException(err);
}
};
Expand Down Expand Up @@ -297,6 +300,15 @@ public static void Build(Options options) {
proc.StartInfo.Arguments += " ";

if(_settings.ecsactBuildEnabled) {
if(_settings.recipes.Count == 0) {
UnityEngine.Debug.LogError(
"No ecsact build recipes selected - please check your Ecsact Unity " +
"settings"
);
Progress.Finish(progressId, Progress.Status.Failed);
return;
}

foreach(var recipe in _settings.recipes) {
if(!string.IsNullOrEmpty(recipe)) {
proc.StartInfo.Arguments += " --recipe=\"";
Expand All @@ -318,7 +330,10 @@ public static void Build(Options options) {
proc.Exited +=
new System.EventHandler(delegate(object sender, System.EventArgs e) {
if(proc.ExitCode != 0) {
UnityEngine.Debug.Log("Ecsact build failed");
UnityEngine.Debug.LogError("Ecsact build failed");
UnityEngine.Debug.Log(
$"From Command: ecsact {proc.StartInfo.Arguments}"
);
} else {
UnityEngine.Debug.Log("Ecsact build succeeded");
}
Expand Down
9 changes: 8 additions & 1 deletion Runtime/AsyncRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace Ecsact {
public class AsyncRunner : EcsactRunner {
private EcsactRuntime? runtime;

public global::System.Int32? sessionId;

private void Enqueue() {
var localExecutionOptions = executionOptions;

Expand All @@ -21,6 +23,7 @@ private void Enqueue() {
localExecutionOptions.create_entities_placeholders.ToArray();
localExecutionOptions.Alloc();
Ecsact.Defaults.Runtime.async.EnqueueExecutionOptions(
sessionId!.Value,
localExecutionOptions.C()
);
} finally {
Expand All @@ -29,11 +32,15 @@ private void Enqueue() {
}

void Update() {
if(!sessionId.HasValue) {
return;
}

if(Ecsact.Defaults.Runtime != null) {
if(!executionOptions.isEmpty()) {
Enqueue();
}
Ecsact.Defaults.Runtime.async.Flush();
Ecsact.Defaults.Runtime.async.Flush(sessionId.Value);
}
}
}
Expand Down
Loading