Provides Reactive extensions to Mirage.
- Mirage >v145
use package manager to get versions easily, or replace #v0.0.6
with the tag, branch or full hash of the commit.
IMPORTANT: update v0.0.6
with latest version on release page
"de.daxten.mirage-reactive-extensions": "https://github.com/Daxten/Mirage-Reactive-Extensions.git?path=/Assets/MirageReactiveExtensions#v0.0.6",
SyncVar<T> MyVar
is similar to [SyncVar] T MyVar
but lifts the Value into AsyncReactiveProperty<T>
.
class A extends NetworkBehaviour {
public SyncVar<int> Health = new(100);
[Server]
public void OnHit() { Health.Value -= 10; }
}
class B extends NetworkBehaviour {
public void ObserveA(A a) {
Health.Where(n => n <= 0).ForEachAsync(e => Debug.Log("My Friend A just died!")), destroyCancellationToken);
}
}
SyncLink<T>
allows you to create a Link/Relation to another Network Object. SyncLink manages all problems associated with this.
- If the object is not spawned yet, it will await for it to spawn and then start syncing it
- If the object gets destroyed, SyncLink will automaticly become "null". All events are triggered as expected.
- SyncLink cleans after itself, no
.Dispose()
or anything required.
You can link objects ahead of time inside the editor.
class A extends NetworkBehaviour { }
class B extends NetworkBehaviour {
SyncLink<A> Linked = new();
}
SyncLinks<T>
allows you to create a Link/Relation to a Set of other Network Objects. SyncLinks manages all problems associated with this.
- If an object is not spawned yet, it will await for it to spawn and then add and sync it.
- If any object gets destroyed, SyncLinks will automaticly remove it from the set. All events are triggered as expected.
- SyncLinks cleans after itself, no
.Dispose()
or anything required.
You can't use the edit at the moment to set SyncLinks<T>
ahead of time.
class A extends NetworkBehaviour { }
class B extends NetworkBehaviour {
SyncLinks<A> Linked = new();
}
To get full Editor support for these, make sure to add the following Compiler Flag to remove the default Mirage Editor:
- Edit
- Project Settings
- Player
- Other Settings
- Script Compilation
- Add
EXCLUDE_NETWORK_BEHAVIOUR_INSPECTOR
Please report any bugs or issues Here
- Simplify Complex Sync Problems