一开始也是试着在 After Effects 中打开脚本编辑器,但弹窗提示如下:
根据提示需要下载 extendScript toolkit,但根据 extendScript toolkit 介绍由于受到 adobe 使用条款等约束已不再维护,且于2019年 adobe 提供了基于 vscode 的 extendScript debugger 插件。
尽管不能替代 extendScript toolkit 的所有功能,还是转战 vscode 试试吧。先下载插件:
如图所示,第二个就是啦!之前在指定文件夹下创建如 test.jsx 文件,后面会自动创建个 launch.json 文件,内容大概如下:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "extendscript-debug",
"request": "attach",
"name": "Attach to ExtendScript Engine",
},
{
"type": "extendscript-debug",
"request": "launch",
"name": "Launch Script in ExtendScript Engine",
}
]
}
之后可在 test.jsx 中测试如下代码,正常的话会在 ae 的信息面板中出现 ”hello world“ 字样:
write("hello world");
如果这时运行代码,会弹窗提示你需要手动选择对应的应用程序:
这里可以在 launch.json 文件中添加配置:
{
"type": "extendscript-debug",
"request": "launch",
"name": "Launch Script in ExtendScript Engine",
"hostAppSpecifier": "aftereffects-18.0",
}
这里属性是 hostAppSpecifier 字段,如果老版本的话,就是 targetSpecifier。重新点击运行后,程序依然不能生效,还有两处需要调整:
第一处是需要将图中箭头指向处选为 launch 版本,另一处是要在文件 launch.json 中配置上脚本路径,即 script 属性,如果老版本的话,就是 program 属性:
{
"type": "extendscript-debug",
"request": "launch",
"name": "Launch Script in ExtendScript Engine",
"hostAppSpecifier": "aftereffects-18.0",
"script": "${workspaceFolder}/test.jsx",
}
这块注意到 test.jsx 文件名是写死的,如果有多个文件调试就得每次都来修改了。不过 vscode 也提供了一个内部变量 ${fileBasename} 可直接引用,动态获取当前文件名。
{
"type": "extendscript-debug",
"request": "launch",
"name": "Launch Script in ExtendScript Engine",
"hostAppSpecifier": "aftereffects-18.0",
"script": "${workspaceFolder}/${fileBasename}",
}
程序终于可以正常执行啦,信息面板中也能看到对应结果:
如果想在 vscode 的控制台也打印输出呢?如下执行即可:
$.write("hello world");
至此,开发环境就算配置完成啦!欢迎交流~