Feather指令是影响Feather如何处理您的GML代码的注释,包括它应用的Feather规则、它使用的Profile以及是否应用严格的类型验证。
默认情况下,Feather指令应用于当前脚本和在其中声明的函数,除非您提供目标路径。
Feather指令具有以下语法:
// Feather command parameters [in PATH]
它是一个正则脚本注释,以Feather开头,后跟命令及其参数。(可选)它可以采用指向资源浏览器中应用该指令的脚本、对象或组的路径。
可以使用指令Feather ignore或Feather disable忽略特定的Feather规则:
// Feather ignore GM1010
// Feather disable GM1010
例如,考虑以下代码段:
// Feather ignore GM1010
result = 5 + "5";
启用严格类型模式后,Feather通常会显示"GM1010 - Cannot perform '+' operation between types 'real' and 'string'消息。使用上述指令,Feather将忽略该特定脚本中的此类型消息。
该指令只影响注释本身之后的行,因此注释之前的任何语句仍将显示警告。
通过添加once,GM消息只能被忽略一次:
// Feather ignore once GM1010
这个命令使Feather忽略第一次出现的这种类型的消息,但不忽略之后出现的消息:
// Feather ignore once GM1010
result = 5 + "5"; // ignored
result = 6 + "6"; // error
最后,您可以使用restore/enable重新启用GM消息:
// Feather restore GM1010
// Feather enable GM1010
此指令设置脚本的配置文件:
// Feather use syntax-errors
// Feather use type-errors
// Feather use all
// Feather use none
此指令从 严格 或 放松 设置要使用的类型验证模式:
/// Feather use strict
/// Feather use relaxed
注意此羽化指令对应于羽化首选项中的严格类型模式首选项。
您还可以在一行中设置配置文件和类型验证模式:
/// Feather use all, strict
上述注释将使Feather查找所有错误并使用严格类型模式。
您也可以使用in指令提供路径,将Feather指令应用于资源浏览器中的特定脚本、对象或组。这可以放在外部函数库的主脚本中,也可以放在任何其他脚本中,例如空白的"FeatherConfig"脚本。
注意使用多个路径的规则可能会导致性能问题,但仅将路径专门设置为*的情况除外。
您可以在路径中使用以下特殊符号:
通过这种方式,可以在资源浏览器中定义资源的路径,例如:
路径 | 适用于 |
---|---|
/Scripts/* | All assets in /Scripts |
/* | All assets |
./* | All assets in the current folder and subfolders |
/Foo/Bar/obj_manager | obj_manager in the /Foo/Bar folder |
示例如下:
指令 | 效果 |
---|---|
// Feather ignore GM2017 in * | Ignores all Naming Rule violations in the whole project |
// Feather ignore GM1064 in ./* | Ignores GM1064 in the current folder and all subfolders |
// Feather use type-errors in /Objects/System/* | Sets the profile to type-errors in specifically the Objects/System folder |
// Feather use all in /Objects/System/obj_controller | Sets the profile to all in obj_controller |
警告如果您有两个指令在同一路径上启用和禁用 Feather 消息,则无法保证结果一致。