首页 > 解决方案 > VS 代码片段

问题描述

我正在尝试在 vscode 中编写自己的代码段。我想知道,是否可以在开发过程中的任何时候添加 Rigidbody 和 Animator 等变量并在函数GetComponent()内部的方法中单独引用它们,而无需重复创建函数(参见下面的代码)。有人知道吗?Start()Start()

"Rigidbody": {
    "prefix": "rb",
    "body": ["Rigidbody $1;",
        "",
        "",
        "void Start(){",
                "\t$1 = GetComponent<Rigidbody>();",

        "}"]
},

"Animator":{
    "prefix": "anim",
    "body": ["Animator $1;",
    "",
    "",
    "void Start(){",
        "\t$1 = GetComponent<Animator>();",
    "}"]
}

标签: unity3dvisual-studio-codevscode-snippets

解决方案


推荐阅读