Hi, so I’m working on a project that I want to press a button to move around a object and set it’s position. To do that I need a button I can press that will change the value of variable in one script from another. In Unity to make it work, you have a reference to a public variable you can access from another script. In Studio, I believe the best way to make it work would be to access the Schema and get the variable there and change it.
How does that work? How do I access another script’s schema that changes the variable in the editor?
import * as ecs from '@8thwall/ecs'
import {World} from '@8thwall/ecs'
import {SingleTap} from './SingleTap'
function TestSet()
{
console.log(SingleTap.schema.PositionSet)
}
ecs.registerComponent({
name: 'ResetPos',
schema: {
// Add data that can be configured on the component.
Setbutton: ecs.eid,
},
schemaDefaults: {
// Add defaults for the schema fields.
},
data: {
// Add data that cannot be configured outside of the component.
},
add: (world, component) => {
// Runs when the component is added to the world.
const {Setbutton} = component.schema
world.events.addListener(Setbutton,'click',TestSet)