Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/skibitsky/asuka

🏭 My Unity extensions and utilities
https://github.com/skibitsky/asuka

unity upm-package

Last synced: about 2 months ago
JSON representation

🏭 My Unity extensions and utilities

Lists

README

        

# asuka

Asuka is the collection of little utilities and extensions I use when working in Unity.

The goal is to create a Unity Package that I could easily plug into any project and avoid reimplementing same things over and over again. It should be as easy as to put Asuka into Eva.

## Third-Party Extensions

I am trying to avoid third-party dependencies in this package. Still need to find a way to share my extensions for third-party libraries. For now, I will just put them below.

### UniRx
UGUI
```csharp
public static IDisposable BindTo(this IReactiveCommand command, Dropdown dropdown)
{
var d1 = command.CanExecute.SubscribeToInteractable(dropdown);
var d2 = dropdown.OnValueChangedAsObservable().SubscribeWithState(command, (x, c) => c.Execute(x));
return StableCompositeDisposable.Create(d1, d2);
}

public static IDisposable BindTo(this IReactiveCommand command, InputField inputField)
{
var d1 = command.CanExecute.SubscribeToInteractable(inputField);
var d2 = inputField.OnValueChangedAsObservable().SubscribeWithState(command, (x, c) => c.Execute(x));
return StableCompositeDisposable.Create(d1, d2);
}

public static IDisposable SubscribeToImage(this IObservable source, Image image)
{
return source.SubscribeWithState(image, (x, i) => image.sprite = x);
}
```

Input System
```csharp
public static IObservable PerformedAsObservable(this InputAction action) =>
Observable.FromEvent(
h => action.performed += h,
h => action.performed -= h);

public static IObservable PerformedAsUnitObservable(this InputAction action) =>
action.PerformedAsObservable().AsUnitObservable();
```