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

Rust importer workflow improvements #27

Merged
merged 10 commits into from
Dec 10, 2024
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
3 changes: 2 additions & 1 deletion WaaS.Unity/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ crashlytics-build.properties
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*

/.idea
/.idea
/target
Empty file.
27 changes: 27 additions & 0 deletions WaaS.Unity/Assets/Component Default.rustimporterpreset.meta

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

33 changes: 33 additions & 0 deletions WaaS.Unity/Assets/RunSequenceTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using MyGame.MySequencer;
using UnityEngine;
using WaaS.ComponentModel.Runtime;
using WaaS.Runtime;
using WaaS.Unity;

public class RunSequenceTest : MonoBehaviour
{
[SerializeField] private ComponentAsset componentAsset;

private async void Start()
{
var component = await componentAsset.LoadComponentAsync();
var instance = component.Instantiate(new Dictionary<string, ISortedExportable>
{
{ "my-game:my-sequencer/env", IEnv.CreateWaaSInstance(new Env()) }
});
using var context = new ExecutionContext();
var sequence = new ISequence.Wrapper(instance, context);
await sequence.Play(); // ぼく「こんにちは!」
}

private class Env : IEnv
{
public ValueTask ShowMessage(string speaker, string message)
{
Debug.Log($"{speaker}「{message}」");
return default;
}
}
}
3 changes: 3 additions & 0 deletions WaaS.Unity/Assets/RunSequenceTest.cs.meta

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

8 changes: 8 additions & 0 deletions WaaS.Unity/Assets/WaaS Generated.meta

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

8 changes: 8 additions & 0 deletions WaaS.Unity/Assets/WaaS Generated/my-game.meta

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

8 changes: 8 additions & 0 deletions WaaS.Unity/Assets/WaaS Generated/my-game/my-sequencer.meta

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

14 changes: 14 additions & 0 deletions WaaS.Unity/Assets/WaaS Generated/my-game/my-sequencer/Env.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// <auto-generated />
#nullable enable

namespace MyGame.MySequencer
{
// interface env
[global::WaaS.ComponentModel.Binding.ComponentInterface(@"env")]
public partial interface IEnv
{
[global::WaaS.ComponentModel.Binding.ComponentApi(@"show-message")]
global::System.Threading.Tasks.ValueTask ShowMessage(string @speaker, string @message);

}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// <auto-generated />
#nullable enable

namespace MyGame.MySequencer
{
// world sequence
[global::WaaS.ComponentModel.Binding.ComponentInterface(@"sequence")]
public partial interface ISequence
{
[global::WaaS.ComponentModel.Binding.ComponentApi(@"play")]
global::System.Threading.Tasks.ValueTask Play();

}
}

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

16 changes: 16 additions & 0 deletions WaaS.Unity/Assets/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use crate::my_game::my_sequencer::env::show_message;

wit_bindgen::generate!({
path: "../../../../../wit",
world: "my-game:my-sequencer/sequence"
});

struct Sequence;

impl Guest for Sequence {
fn play() {
show_message("ぼく", "こんにちは!");
}
}

export!(Sequence);
21 changes: 21 additions & 0 deletions WaaS.Unity/Assets/test.rs.meta

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

Loading