behavior.js主要配置行为

常量

  1. const BEHAVIOR_ID = "MyCompany_MyAddon";
  2. const BEHAVIOR_VERSION = "1.0.0.0";
  3. const BEHAVIOR_CATEGORY = "general";

BEHAVIOR_ID

必须和addon.json中ID的值相同

BEHAVIOR_VERSION

必须和addon.json中version的值相同

BEHAVIOR_CATEGORY

当在对话框中添加behavior,展示的行为类别, 可选值为:

  • attributes
  • general
  • movements
  • other
  1. class MyCustomBehavior extends SDK.IBehaviorBase {
  2. constructor () {
  3. super();
  4. }
  5. }
  6. const BEHAVIOR_CLASS = MyCustomBehavior;
  7. SDK.Behaviors.MyCompany_MyAddon = MyCustomBehavior;

在构造函数中,插件的配置是通过this._info设置的,这是一个IPluginInfo的接口

当选中行为实例时,行为属性会出现在属性栏,你需要这样设置属性:

  1. this._info.SetProperties([
  2. new SDK.PluginProperty("integer", "test-property", 0)
  3. ]);
  • 在对象实例属性中,点击添加behavior 常量 - 图1

常量 - 图2

  • 在常规中就会发现插件定义的behavior 常量 - 图3

  • 双击即可添加 常量 - 图4

在刚才的对象实例属性中,即可看到这个behavior

常量 - 图5