Behavior callback userId => user (#34)

This commit is contained in:
Steven Vergenz 2019-04-05 13:12:06 -07:00 коммит произвёл GitHub
Родитель a6e9ada58a
Коммит b3f1898d89
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 13 добавлений и 13 удалений

Просмотреть файл

@ -107,17 +107,17 @@ export default class HelloWorld {
const buttonBehavior = this.cube.setBehavior(ButtonBehavior);
// Trigger the grow/shrink animations on hover.
buttonBehavior.onHover('enter', (userId: string) => {
buttonBehavior.onHover('enter', () => {
this.cube.animateTo(
{ transform: { local: { scale: { x: 0.5, y: 0.5, z: 0.5 } } } }, 0.3, AnimationEaseCurves.EaseOutSine);
});
buttonBehavior.onHover('exit', (userId: string) => {
buttonBehavior.onHover('exit', () => {
this.cube.animateTo(
{ transform: { local: { scale: { x: 0.4, y: 0.4, z: 0.4 } } } }, 0.3, AnimationEaseCurves.EaseOutSine);
});
// When clicked, do a 360 sideways.
buttonBehavior.onClick('pressed', (userId: string) => {
buttonBehavior.onClick('pressed', () => {
this.cube.enableAnimation('DoAFlip');
});
}

Просмотреть файл

@ -67,13 +67,13 @@ export default class SolarSystem {
sunPrimitives.forEach((prim) => {
// Add a collider so that the behavior system will work properly on Unity host apps.
const center = { x: 0, y: 0, z: 0} as MRESDK.Vector3Like;
const center = { x: 0, y: 0, z: 0 } as MRESDK.Vector3Like;
const radius = 3;
prim.setCollider('sphere', false, center, radius);
const buttonBehavior = prim.setBehavior(MRESDK.ButtonBehavior);
buttonBehavior.onClick('pressed', (userId: string) => {
buttonBehavior.onClick('pressed', () => {
if (this.animationsRunning) {
this.pauseAnimations();
this.animationsRunning = false;
@ -83,11 +83,11 @@ export default class SolarSystem {
}
});
buttonBehavior.onHover('enter', (userId: string) => {
buttonBehavior.onHover('enter', () => {
console.log(`Hover entered on ${sunEntity.model.name}.`);
});
buttonBehavior.onHover('exit', (userId: string) => {
buttonBehavior.onHover('exit', () => {
console.log(`Hover exited on ${sunEntity.model.name}.`);
});
});

Просмотреть файл

@ -179,20 +179,20 @@ export default class TicTacToe {
const buttonBehavior = cube.setBehavior(ButtonBehavior);
// Trigger the grow/shrink animations on hover.
buttonBehavior.onHover('enter', (userId: string) => {
buttonBehavior.onHover('enter', () => {
if (this.gameState === GameState.Play &&
this.boardState[tileIndexX * 3 + tileIndexZ] === undefined) {
cube.enableAnimation('GrowIn');
}
});
buttonBehavior.onHover('exit', (userId: string) => {
buttonBehavior.onHover('exit', () => {
if (this.gameState === GameState.Play &&
this.boardState[tileIndexX * 3 + tileIndexZ] === undefined) {
cube.enableAnimation('ShrinkOut');
}
});
buttonBehavior.onClick('pressed', (userId: string) => {
buttonBehavior.onClick('pressed', () => {
switch (this.gameState) {
case GameState.Intro:
this.beginGameStatePlay();

Просмотреть файл

@ -108,7 +108,7 @@ export default class WearAHat {
// Set a click handler on the button.
button.value.setBehavior(MRESDK.ButtonBehavior)
.onClick('released', (userId: string) => this.wearHat(hatId, userId));
.onClick('released', user => this.wearHat(hatId, user.id));
// Create a label for the menu entry.
MRESDK.Actor.CreateEmpty(this.context, {

Просмотреть файл

@ -1,3 +1,3 @@
{
"sdkPath": "..\\..\\..\\mixed-reality-extension-sdk"
{
"sdkPath": "..\\..\\..\\mixed-reality-extension-sdk\\packages\\sdk"
}