Skip to main content
Version: v1.1

Commands

info

This page shows an example of sending a command from MetaEditor to Unreal Engine.

Example

import Button from '@mui/material/Button';
import { usePlayer } from 'metaeditor/context/'

function Demo() {
const player = usePlayer()

const handleCommand = async (event) => {

await player.cmd.emit({
command: 'my_command_1',
request: {
// The request body should only contain a json object.
body: { rotate: true },
},

// If the callback emulation option is enabled, then the contents of fakeResponse will be returned as response.body
fakeResponse: undefined,
}).then(res => {
console.log(res)
})

}

return (
<MetaEditor {...props}>
<Button onClick={handleCommand}>
Send command to Unreal Engine
</Button>
</MetaEditor>
)
}
danger

Demo function must be a child of the MetaEditor component.

export default function App(props) {
return (
<MetaEditor {...props}>
<Demo />
</MetaEditor>
)
}

Parameters

KeysFormatDefault valueDescription
commandstringThe unique command name that Unreal Engine will receive.
Type: slug (lowercase, no spaces)
request.bodyjson{}An object with the data that Unreal Engine will receive as the contents of the command.
verification_idstringundefinedThis is the unique identifier for the command. With it, you can distinguish between two identical commands sent to the Unreal Engine.

If you specify undefined", then MetaEditor will automatically assign a sequence number.
fakeResponsejsonfalseCallback emulation for testing commands without waiting for a callback from Unreal Engine.