Last active
January 12, 2021 04:03
-
-
Save koji/8e5f8ac4aa4bc753266594d99117827e to your computer and use it in GitHub Desktop.
Native UI Picker for SparkAR Studio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Scene = require("Scene"); | |
const NativeUI = require("NativeUI"); | |
const Textures = require("Textures"); | |
const Materials = require("Materials"); | |
(async function () { | |
const button1 = await Textures.findFirst("texture0"); | |
const button2 = await Textures.findFirst("texture1"); | |
const button3 = await Textures.findFirst("texture2"); | |
const mat1 = await Materials.findFirst("bgMaterial1"); | |
const mat2 = await Materials.findFirst("bgMaterial2"); | |
const mat3 = await Materials.findFirst("bgMaterial3"); | |
const bg = await Scene.root.findFirst("background"); | |
const config = { | |
selectedIndex: 0, | |
items: [ | |
{ image_texture: button1 }, | |
{ image_texture: button2 }, | |
{ image_texture: button3 }, | |
], | |
mats: [{ material: mat1 }, { material: mat2 }, { material: mat3 }], | |
}; | |
const picker = NativeUI.picker; | |
picker.configure(config); | |
picker.visible = true; | |
picker.selectedIndex.monitor().subscribe((val) => { | |
bg.material = config.mats[val.newValue].material; | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment