diff --git a/packages/shader-lab/src/preprocessor/PpParser.ts b/packages/shader-lab/src/preprocessor/PpParser.ts index 025d311cc0..5122a5b493 100644 --- a/packages/shader-lab/src/preprocessor/PpParser.ts +++ b/packages/shader-lab/src/preprocessor/PpParser.ts @@ -6,7 +6,7 @@ import PpSourceMap, { BlockInfo } from "./sourceMap"; // #endif import { BaseToken } from "../common/BaseToken"; import { ParserUtils } from "../Utils"; -import { EPpKeyword, EPpToken, PpConstant } from "./constants"; +import { EEditorKeywords, EPpKeyword, EPpToken, PpConstant } from "./constants"; import PpScanner from "./PpScanner"; import { PpUtils } from "./Utils"; import { ShaderLab } from "../ShaderLab"; @@ -622,7 +622,7 @@ export default class PpParser { } private static _skipEditorBlock(token: BaseToken, scanner: PpScanner) { - if (token.lexeme === "EditorProperties" || token.lexeme === "EditorMacros") { + if (token.lexeme === EEditorKeywords.Property || token.lexeme === EEditorKeywords.Macro) { const start = scanner.current - token.lexeme.length; scanner.scanPairedBlock("{", "}"); const end = scanner.current; @@ -630,6 +630,14 @@ export default class PpParser { const endPosition = ShaderLab.createPosition(end); const range = ShaderLab.createRange(startPosition, endPosition); this.expandSegments.push({ rangeInBlock: range, replace: "" }); + } else if (token.lexeme === EEditorKeywords.Script) { + const start = scanner.current - token.lexeme.length; + scanner.scanQuotedString(); + const end = scanner.current; + const startPosition = ShaderLab.createPosition(start); + const endPosition = ShaderLab.createPosition(end); + const range = ShaderLab.createRange(startPosition, endPosition); + this.expandSegments.push({ rangeInBlock: range, replace: "" }); } } diff --git a/packages/shader-lab/src/preprocessor/constants.ts b/packages/shader-lab/src/preprocessor/constants.ts index 98a8912213..fced1372bd 100644 --- a/packages/shader-lab/src/preprocessor/constants.ts +++ b/packages/shader-lab/src/preprocessor/constants.ts @@ -70,3 +70,9 @@ export const PpKeyword = new Map([ ]); export type PpConstant = boolean | number; + +export enum EEditorKeywords { + Property = "EditorProperties", + Macro = "EditorMacros", + Script = "EditorScript" +}