SparkAR Community Scripting Docs
  • Spark AR Scripting Reference
  • Audio Analyzer / Energy Meter
  • Asynchronous API Changes (v85+)
  • Custom Instructions
  • AnimationModule
    • ValueDriver
    • TimeDriver
    • SignalRecorder
    • SignalRecord
    • ScalarSampler
    • SamplerFactory
    • RotationSampler
    • Driver
    • ColorSampler
    • ArrayOfScalarSignals
    • ArrayOfScalarSamplers
  • AudioModule
    • PlaybackController
  • CameraInfoModule
    • CameraPosition
  • DeepLinkModule
  • DeviceMotionModule
  • DiagnosticsModule
  • FaceGesturesModule
  • FaceTracking2DModule
    • Face2D
  • FaceTrackingModule
    • Cheek
    • Chin
    • Eye
    • Eyebrow
    • Face
    • Forehead
    • Mouth
    • Nose
  • FontsModule
    • FontId
  • HandTrackingModule
    • Hand
  • InstructionModule
  • IrisTrackingModule
    • Eyeball
  • LightingEstimationModule
  • LiveStreamingModule
    • LiveStreamingModule.State
    • LiveStreamingReactions
    • LiveStreamingComments
  • LocaleModule
  • MaterialsModule
    • TextureTransform
    • RetouchingMaterial
    • MetallicRoughnessPbrMaterial
    • MaterialBase
    • DefaultMaterial
    • ColorPaintMaterial
    • BlendShapeToWarpMapMaterial
    • BlendedMaterial
  • NativeUIModule
    • Picker
  • NetworkingModule
  • PatchesModule
  • PersistenceModule
    • StorageScope
  • PersonSegmentationModule
  • RandomModule
  • ReactiveModule
    • AntiderivativeOverflowBehaviour
    • BoundingBoxSignal
    • ISignal
    • PixelPointSignal
    • PixelSizeSignal
    • Point2D
    • Point2DSignal
    • Point3D
    • Point4DSignal
    • PointSignal
    • PrimitiveOrShaderSignal
    • RgbaSignal
    • BoolSignal
    • Rotation
    • RotationSignal
    • ScalarSignal
    • ScalarValue
    • ScaleSignal
    • ShaderSignal
    • StringSignal
    • StringValue
    • Subscription
    • BoolValue
    • VectorSignal
    • TransformSignal
    • ColorSignal
    • EulerAnglesSignal
    • EventSource
    • HsvaSignal
    • InsetsSignal
  • SceneModule
    • AmbientLightSource
    • BrushType
    • HorizontalAlignment
    • RenderMode
    • ScalingOption
    • TextAlignment
    • TrackingMode
    • SpotLightSource
    • PointLightSource
    • DirectionalLightSource
    • HandTrackerSceneObject
    • Canvas
    • DynamicExtrusion
    • FaceAnchor
    • FaceMesh
    • VerticalTextAlignment
    • VerticalAlignment
    • FaceTracker
    • FocalPlane
    • FocalDistance
    • OutputVisibility
    • Mesh
    • Joint
    • PlaneTracker
    • Plane
    • PlanarText
    • PlanarObject
    • PlanarImage
    • PlanarFlexItem
    • PlanarDiv
    • ParticleTypeDescriptions
    • ParticleSystem
    • ParticleTypeDescription
    • PlanarFlexContainer
    • TextExtrusion
    • SvgImage
    • BlendShapesMesh
    • BlockSceneRoot
    • BoundingBox
    • Bounds2D
    • Camera
    • CameraVisibility
    • BlendShape
    • Scene
    • SceneObjectBase
    • ScreenPlane
    • Skeleton
    • segmentation
    • Speaker
    • Transform
    • TargetTracker
    • TextAlignmentWrapper
    • WorldTransform
    • SceneObject
  • ShadersModule
    • VertexAttribute
    • SdfVariant
    • PhysicallyBasedMaterialTextures
    • GradientType
    • FacePaintMaterialTextures
    • DerivativeType
    • DefaultMaterialTextures
    • ColorSpace
    • BuiltinUniform
    • BlendMode
    • BlendedMaterialTextures
  • SvgsModule
  • TexturesModule
    • State
    • SourceImageRegionTexture
    • SubTexture
    • TextureBase
    • CameraTexture
    • CanvasTexture
    • ColorTexture
    • DeepLinkTexture
    • ExternalTexture
    • ImageTexture
    • SegmentationTexture
    • SequenceTexture
  • TimeModule
  • TouchGesturesModule
    • Type
    • TouchGestureModule.Gesture.State
    • Gesture
    • LongPressGesture
    • PanGesture
    • PinchGesture
    • RawTouchGesture
    • RotateGesture
    • TapGesture
  • UnitsModule
Powered by GitBook
On this page
  • Example
  • Properties
  • Methods

Was this helpful?

  1. NativeUIModule

Picker

The Picker class describes an object controlling native picker behavior.

Example

//==============================================================================
// The following example demonstrates how to configure, show and use a NativeUI
// picker.
//
// Project setup:
// - Insert a plane
// - Create a material and assign it to the plane
// - Import textures for use in the picker (set these textures to uncompressed)
//==============================================================================

// Load in the required modules
const NativeUI = require('NativeUI');
const Scene = require('Scene');
const Textures = require('Textures');

// Locate the plane in the Scene
const plane = Scene.root.find('plane0');

//==============================================================================
// Setup the configuration for the picker
//==============================================================================

// Locate the textures in the Assets
const texture0 = Textures.get('texture0');
const texture1 = Textures.get('texture1');
const texture2 = Textures.get('texture2');

// Store a reference to the picker
const picker = NativeUI.picker;

// Set a starting index (optional, will be 0 by default)
const index = 0;

// Create a configuration object
const configuration = {

  // The index of the selected item in the picker
  selectedIndex: index,

  // The image textures to use as the items in the picker
  items: [
    {image_texture: texture0},
    {image_texture: texture1},
    {image_texture: texture2},
    {image_texture: texture0},
    {image_texture: texture1},
    {image_texture: texture2},
    {image_texture: texture0},
    {image_texture: texture1},
    {image_texture: texture2}
  ]

};

//==============================================================================
// Apply the configuration and show the picker
//==============================================================================

// Configure the picker using the configuration object
picker.configure(configuration);

// Set the picker to be visible (visible is false by default)
picker.visible = true;

//==============================================================================
// Use the picker to set the texture of the plane
//==============================================================================

// Subscribe to the selectedIndex scalar signal
picker.selectedIndex.monitor().subscribe(function(index) {
  // Update the texture of the material assigned to the plane to be the selected
  // texture
  plane.material.diffuse = configuration.items[index.newValue].image_texture;
});

Properties

Property

Description

selectedIndex

(get) selectedIndex: ScalarSignal (set) selectedIndex: ScalarSignal

Represents the index of the selected item in the picker.

visible

(set) visible: BoolSignal Will instruct picker to be visible or not visible, according to passed boolean value.

Methods

Method

Description

configure

configure(configuration: {selectedIndex?: int, items: [{image_texture: ImageTexture}]}): void Configures the picker with a given JSON configuration. The configuration consists of an optional initial selected index (0 will be used if not specified) and a list of items. For items you must specify a name of an uncompressed texture which will be used as the picker item image.

PreviousNativeUIModuleNextNetworkingModule

Last updated 5 years ago

Was this helpful?