Unity解决VsCode某些项目可以代码提示,某些项目不能代码智能提示

在百度上找不到解决办法的一定要看我这个方法!!!!!!

前些天在电脑上装了写东西,今天打开我的Unity的c#脚本,发现莫名奇妙智能提示消失了,或者只能提示一部分。关键是只是一部分项目的智能提示消失了,其他的项目都还好好的,不知道抽了什么风。然后我百度几乎用了所有方法,结果发现没用,我就开始找不同,终于解决了,而且巨简单。

能智能提示的项目的是这样子的,

Unity解决VsCode某些项目可以代码提示,某些项目不能代码智能提示_第1张图片

不能智能提示的项目是这样子的

Unity解决VsCode某些项目可以代码提示,某些项目不能代码智能提示_第2张图片

然后我发现有智能提示的项目。左边的Packages文件夹目录下是有一个packages-lock.json,如下图

Unity解决VsCode某些项目可以代码提示,某些项目不能代码智能提示_第3张图片

 而且在.sln文件里是多出来这样一段代码

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{2a737568-0b73-8fc0-84b1-a953fef9afcf}"
EndProject

Unity解决VsCode某些项目可以代码提示,某些项目不能代码智能提示_第4张图片

然后我就在那没有代码提示的项目里,手动将那个packages-lock.json文件完完整整的复制过去,

 Unity解决VsCode某些项目可以代码提示,某些项目不能代码智能提示_第5张图片

粘贴到没有这个文件的项目里

 Unity解决VsCode某些项目可以代码提示,某些项目不能代码智能提示_第6张图片

 并且在.sln文件里把那段代码复制过去

Unity解决VsCode某些项目可以代码提示,某些项目不能代码智能提示_第7张图片

 然后关闭整个Unity项目再重新打开,我发现就可以智能提示啦!!!而且不仅如此,我把一个项目的这样子弄,其他所有的项目自动就跟着一起改动,所有的项目都有智能提示了。

Unity解决VsCode某些项目可以代码提示,某些项目不能代码智能提示_第8张图片

 附上packages-lock.json源码,如果大家没有packages-lock.json.大家可以直接新建一个文件,命名为packages-lock.json,把底下的源码复制到里面,一样的效果,不需要任何修改,不要忘记在.sln文件里面把那一小段代码加上哦。

{
  "dependencies": {
    "com.unity.2d.animation": {
      "version": "3.2.9",
      "depth": 0,
      "source": "registry",
      "dependencies": {
        "com.unity.2d.common": "2.1.0",
        "com.unity.mathematics": "1.1.0",
        "com.unity.2d.sprite": "1.0.0",
        "com.unity.modules.animation": "1.0.0",
        "com.unity.modules.uielements": "1.0.0"
      },
      "url": "https://packages.unity.cn"
    },
    "com.unity.2d.common": {
      "version": "2.1.0",
      "depth": 1,
      "source": "registry",
      "dependencies": {
        "com.unity.2d.sprite": "1.0.0",
        "com.unity.modules.uielements": "1.0.0"
      },
      "url": "https://packages.unity.cn"
    },
    "com.unity.2d.path": {
      "version": "2.1.1",
      "depth": 1,
      "source": "registry",
      "dependencies": {},
      "url": "https://packages.unity.cn"
    },
    "com.unity.2d.pixel-perfect": {
      "version": "2.1.0",
      "depth": 0,
      "source": "registry",
      "dependencies": {},
      "url": "https://packages.unity.cn"
    },
    "com.unity.2d.psdimporter": {
      "version": "2.1.8",
      "depth": 0,
      "source": "registry",
      "dependencies": {
        "com.unity.2d.common": "2.1.0",
        "com.unity.2d.animation": "3.2.9",
        "com.unity.2d.sprite": "1.0.0"
      },
      "url": "https://packages.unity.cn"
    },
    "com.unity.2d.sprite": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.2d.spriteshape": {
      "version": "3.0.17",
      "depth": 0,
      "source": "registry",
      "dependencies": {
        "com.unity.mathematics": "1.1.0",
        "com.unity.2d.common": "2.1.0",
        "com.unity.2d.path": "2.1.1"
      },
      "url": "https://packages.unity.cn"
    },
    "com.unity.2d.tilemap": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.cinemachine": {
      "version": "2.5.0",
      "depth": 0,
      "source": "registry",
      "dependencies": {},
      "url": "https://packages.unity.cn"
    },
    "com.unity.collab-proxy": {
      "version": "1.12.5",
      "depth": 0,
      "source": "registry",
      "dependencies": {},
      "url": "https://packages.unity.cn"
    },
    "com.unity.ext.nunit": {
      "version": "1.0.6",
      "depth": 1,
      "source": "registry",
      "dependencies": {},
      "url": "https://packages.unity.cn"
    },
    "com.unity.ide.rider": {
      "version": "1.2.1",
      "depth": 0,
      "source": "registry",
      "dependencies": {
        "com.unity.test-framework": "1.1.1"
      },
      "url": "https://packages.unity.cn"
    },
    "com.unity.ide.visualstudio": {
      "version": "2.0.11",
      "depth": 0,
      "source": "registry",
      "dependencies": {
        "com.unity.test-framework": "1.1.9"
      },
      "url": "https://packages.unity.cn"
    },
    "com.unity.ide.vscode": {
      "version": "1.2.4",
      "depth": 0,
      "source": "registry",
      "dependencies": {},
      "url": "https://packages.unity.cn"
    },
    "com.unity.mathematics": {
      "version": "1.1.0",
      "depth": 1,
      "source": "registry",
      "dependencies": {},
      "url": "https://packages.unity.cn"
    },
    "com.unity.test-framework": {
      "version": "1.1.29",
      "depth": 0,
      "source": "registry",
      "dependencies": {
        "com.unity.ext.nunit": "1.0.6",
        "com.unity.modules.imgui": "1.0.0",
        "com.unity.modules.jsonserialize": "1.0.0"
      },
      "url": "https://packages.unity.cn"
    },
    "com.unity.textmeshpro": {
      "version": "2.1.4",
      "depth": 0,
      "source": "registry",
      "dependencies": {
        "com.unity.ugui": "1.0.0"
      },
      "url": "https://packages.unity.cn"
    },
    "com.unity.timeline": {
      "version": "1.2.18",
      "depth": 0,
      "source": "registry",
      "dependencies": {
        "com.unity.modules.director": "1.0.0",
        "com.unity.modules.animation": "1.0.0",
        "com.unity.modules.audio": "1.0.0",
        "com.unity.modules.particlesystem": "1.0.0"
      },
      "url": "https://packages.unity.cn"
    },
    "com.unity.ugui": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.ui": "1.0.0",
        "com.unity.modules.imgui": "1.0.0"
      }
    },
    "com.unity.modules.ai": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.androidjni": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.animation": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.assetbundle": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.audio": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.cloth": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.physics": "1.0.0"
      }
    },
    "com.unity.modules.director": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.audio": "1.0.0",
        "com.unity.modules.animation": "1.0.0"
      }
    },
    "com.unity.modules.imageconversion": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.imgui": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.jsonserialize": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.particlesystem": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.physics": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.physics2d": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.screencapture": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.imageconversion": "1.0.0"
      }
    },
    "com.unity.modules.subsystems": {
      "version": "1.0.0",
      "depth": 1,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.jsonserialize": "1.0.0"
      }
    },
    "com.unity.modules.terrain": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.terrainphysics": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.physics": "1.0.0",
        "com.unity.modules.terrain": "1.0.0"
      }
    },
    "com.unity.modules.tilemap": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.physics2d": "1.0.0"
      }
    },
    "com.unity.modules.ui": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.uielements": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.imgui": "1.0.0",
        "com.unity.modules.jsonserialize": "1.0.0"
      }
    },
    "com.unity.modules.umbra": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.unityanalytics": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.unitywebrequest": "1.0.0",
        "com.unity.modules.jsonserialize": "1.0.0"
      }
    },
    "com.unity.modules.unitywebrequest": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.unitywebrequestassetbundle": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.assetbundle": "1.0.0",
        "com.unity.modules.unitywebrequest": "1.0.0"
      }
    },
    "com.unity.modules.unitywebrequestaudio": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.unitywebrequest": "1.0.0",
        "com.unity.modules.audio": "1.0.0"
      }
    },
    "com.unity.modules.unitywebrequesttexture": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.unitywebrequest": "1.0.0",
        "com.unity.modules.imageconversion": "1.0.0"
      }
    },
    "com.unity.modules.unitywebrequestwww": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.unitywebrequest": "1.0.0",
        "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
        "com.unity.modules.unitywebrequestaudio": "1.0.0",
        "com.unity.modules.audio": "1.0.0",
        "com.unity.modules.assetbundle": "1.0.0",
        "com.unity.modules.imageconversion": "1.0.0"
      }
    },
    "com.unity.modules.vehicles": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.physics": "1.0.0"
      }
    },
    "com.unity.modules.video": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.audio": "1.0.0",
        "com.unity.modules.ui": "1.0.0",
        "com.unity.modules.unitywebrequest": "1.0.0"
      }
    },
    "com.unity.modules.vr": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.jsonserialize": "1.0.0",
        "com.unity.modules.physics": "1.0.0",
        "com.unity.modules.xr": "1.0.0"
      }
    },
    "com.unity.modules.wind": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {}
    },
    "com.unity.modules.xr": {
      "version": "1.0.0",
      "depth": 0,
      "source": "builtin",
      "dependencies": {
        "com.unity.modules.physics": "1.0.0",
        "com.unity.modules.jsonserialize": "1.0.0",
        "com.unity.modules.subsystems": "1.0.0"
      }
    }
  }
}

你可能感兴趣的:(vscode,unity)