PickerHandler
PickerHandler is a wrapper of NativeUI.picker in Spark AR. Please note that this tool is Script Only. Although there is a sample project show how to use this tool with Patch Editor, this libaray is not Patch friendly.
Install
Import
-
Download PickerHandler (Right click and Save as)
-
Drap/Import them to Assets caetgory in Spark AR.
-
Use
require
to import this module at the top of your script.const Picker = ;// Your script... -
You can also Click Here to Download Sample Projects.
npm
-
Add package with
yarn
ornpm
yarn add sparkar-picker-handleror
npm i sparkar-picker-handler -
Use
require
to import this moduleconst Picker = ;// Your script...
Usage
// Picker.configUsingPattern('img_picker_*').then(subscribeFunctions);// Picker.configUsingNames(['img_picker_0', 'img_picker_1']).then(subscribeFunctions);Picker; { Picker; Picker; Picker; Picker; Picker;}
Default configure
You need to call the config
function manually. For very basic useage, you can just call configUsingDefault()
.
Picker
And then set the "DEFAULT" field in PickerHandler.js
//–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– DEFAULTconst initalIndex = 0;const texturesName = 'img_picker_0' 'img_picker_1'; //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
Manually configure
First, set the picker visible manually.
Picker;
You can config picker with array of names or name pattern.
Picker;// orPicker
Since configUsingPattern()
will get picker images in random order, you can pass your prefer sort function.
const mySort = n1 - n2; Picker;
Subscribe Functions
You can then subscribe your selected function after configuring the picker.
Picker;
Other Functions
unsubscribeAll()
: Unsubscribe all selceted function.
setIndex()
: Set PickerHandler to desired index.
setVisible()
: Set PickerHandler to desired index.
Donations
If this is useful for you, please consider a donation🙏🏼. One-time donations can be made with PayPal.