0

在 Native UI Picker 的文档页面中它说:“NativeUI Picker 是一个您可以添加到效果的界面。它允许使用您的效果的人们通过选择图标来选择其中的不同选项。例如,用户可以点击不同的图标来更改效果中显示的纹理"

我用 NativeUI 纹理“切换器”制作了几个效果,并试图实现 NativeUI 不是在纹理之间切换,而是在效果(对象)本身之间切换。

例如,如果我要制作一个带有一些纹理的 FaceMesh,它会随着屏幕点击而改变,而粒子系统也会随着屏幕被点击而改变。我如何使用 NativeUI 在这两者之间切换?

我不太喜欢我目前的解决方案,因为它对用户不友好。我使用了 PatchEditor 和 FaceFinder,当眉毛抬起时打开/关闭 faceMesh 和 Emitter 的可见性。请看下面的截图:

Spark AR 补丁编辑器 我真的很感激任何建议,谢谢!

4

1 回答 1

0
// Load in modules
const NativeUI = require("NativeUI");
const Textures = require("Textures");
const Patches = require("Patches");

export const Diagnostics = require("Diagnostics");

// Create a number
let userNumber = 0;

const texture0 = Textures.get("number1");
const texture1 = Textures.get("number2");
const texture2 = Textures.get("number3");

const index = 0;
const configuration = {
  selectedIndex: index,
  items: [
    { image_texture: texture0 },
    { image_texture: texture1 },
    { image_texture: texture2 }
  ]
};
const picker = NativeUI.picker;
picker.configure(configuration);
picker.visible = true;

picker.selectedIndex.monitor().subscribe(function(index) {
  userNumber = index.newValue;
  // Send the number to the Patch Editor under the name 'userNumber'
  Patches.setScalarValue("userNumber", userNumber);
  // Debugging
  Diagnostics.log("user selection = " + index.newValue);
});

使用 NativeUI 选择器。上面的代码会将索引值作为 userNumber(scalar) 输出到补丁编辑器。

示例:如果用户选择数字 1,则 userNumber 的输出将为 0,如果用户选择数字 2,则 userNumber 的输出将为 1,如果用户选择数字 3,则 userNumber 的输出将为 2,以此类推。

您可以将 userNumber 用作 switch 与完全相等的 NativeUI Picker 作为 Switch Picture

于 2020-02-08T02:24:07.707 回答