import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { validatePath } from '@xrengine/common/src/utils/validatePath' import { useComponent } from '@xrengine/engine/src/ecs/functions/ComponentFunctions' import { SystemUpdateType } from '@xrengine/engine/src/ecs/functions/SystemUpdateType' import { SystemComponent } from '@xrengine/engine/src/scene/components/SystemComponent' import ExtensionIcon from '@mui/icons-material/Extension' import BooleanInput from '../inputs/BooleanInput' import InputGroup from '../inputs/InputGroup' import ScriptInput from '../inputs/ScriptInput' import { SelectInput } from '../inputs/SelectInput' import StringInput from '../inputs/StringInput' import NodeEditor from './NodeEditor' import { EditorComponentType, updateProperties, updateProperty } from './Util' /** * Define properties for Script component. * * @type {Object} */ const systemUpdateTypes = [ { label: 'None', value: 'None' }, { label: 'Update', value: SystemUpdateType.UPDATE }, { label: 'Fixed Early', value: SystemUpdateType.FIXED_EARLY }, { label: 'Fixed', value: SystemUpdateType.FIXED }, { label: 'Fixed Late', value: SystemUpdateType.FIXED_LATE }, { label: 'Pre Render', value: SystemUpdateType.PRE_RENDER }, { label: 'Post Render', value: SystemUpdateType.POST_RENDER } ] /** * For Scripts * * @param {Object} props * @constructor */ export const SystemNodeEditor: EditorComponentType = (props) => { const [isPathValid, setPathValid] = useState(true) const { t } = useTranslation() const onChangePath = (path) => { if (validatePath(path)) { updateProperties(SystemComponent, { filePath: path }) setPathValid(true) } else { setPathValid(false) } } const systemComponent = useComponent(props.entity, SystemComponent).value return ( {!isPathValid &&
{t('editor:properties.systemnode.error-url')}
}
) } SystemNodeEditor.iconComponent = ExtensionIcon export default SystemNodeEditor