Skip to content

Instantly share code, notes, and snippets.

@skang2-sc
Created February 21, 2025 04:21
Show Gist options
  • Save skang2-sc/ec2048df8af1a70c512a254b87a5e745 to your computer and use it in GitHub Desktop.
Save skang2-sc/ec2048df8af1a70c512a254b87a5e745 to your computer and use it in GitHub Desktop.
ToggleImage with Spectacles Interaction Kit
import { PinchButton } from "SpectaclesInteractionKit/Components/UI/PinchButton/PinchButton";
@component
export class ToggleImage extends BaseScriptComponent {
@input
image: Image;
onAwake() {
this.sceneObject
.getComponent(PinchButton.getTypeName())
.onButtonPinched.add(() => {
this.toggleImage();
});
}
toggleImage() {
this.image.enabled = !this.image.enabled;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment