unity device - crashkonijn/AirController GitHub Wiki
Device
Minimal/Example implementation
using SwordGC.AirController;
public class ExampleDevice : Device {
public ExampleDevice (int deviceId) : base(deviceId)
{
}
// required
public override string View
{
get
{
if (Player == null) return "NotJoined";
else return "Joined";
}
}
// purely example
public override string Classes
{
get
{
return "Color" + player.ColorId;
}
}
}
Variables
// Reference to the input of this device
public Input Input { get; protected set; }
// Reference to the save data of this device
public SaveData SaveData { get; private set; }
// Set to true when this specific device is here
private bool isHero;
// Returns true when this device is hero or heromode === TOGETHER and there's at least one hero in the party
public bool IsHero;
// The id of this device
public int DeviceId { get; private set; }
// Returns the playerId of the claimed player.
// When no player is claimed it will return -1
public int PlayerId;
// Returns the connected player
public Player Player;
// True if this device has a player object
public bool HasPlayer;
// Returns the Nickname of this device
public string Nickname;
// Should return the current view of the controller
public virtual string View;
// Should return the classes that should be inserted on the controller
public virtual string Classes;
// Holds the profile picture of the device in 512x512 px
public Texture2D ProfilePicture { get; private set; }
Methods
// Set's custom data that is sent to the controller
public void SetData (string key, string data) {}
Below is an example of how to grab data within Vue
export default {
computed: {
score() {
return this.$store.getters.getCustomData("score");
}
},
}