Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
362 views
in Technique[技术] by (71.8m points)

c# - How to view Unity method implementations in VSCode "Jump To Definition"?

I have a friend using JetBrains Rider and when he uses Jump To Definition (F12) he can see the method signature and implementation! I tried installing Rider but it is not yet supported on my ARM64 Mac. Is there anyway I can view Unity method implementations using VSCode or VSCode Insiders?

For example, if I have the following call, I click Translate

transform.Translate(Vector3.forward * Time.deltaTime * zSpeed);

Then I press F12, which opens Transform.cs but only shows the method headers. The implementations are missing

// Summary:
//     Moves the transform by x along the x axis, y along the y axis, and z along the
//     z axis.
//
// Parameters:
//   x:
//
//   y:
//
//   z:
//
//   relativeTo:
public void Translate(float x, float y, float z);

// comments removed for brevity...
public void Translate(float x, float y, float z, [DefaultValue("Space.Self")] Space relativeTo);

// comments removed for brevity...
public void Translate(Vector3 translation);

// comments removed for brevity...
public void Translate(Vector3 translation, [DefaultValue("Space.Self")] Space relativeTo);

// comments removed for brevity...
public void Translate(float x, float y, float z, Transform relativeTo);

// comments removed for brevity...
public void Translate(Vector3 translation, Transform relativeTo);

Any help is greatly appreciated!


Per a comment, I tried Cmd+F12

cmd-f12

But then it says "no implementation found"

no-implementation

I'm stuck!

question from:https://stackoverflow.com/questions/65835426/how-to-view-unity-method-implementations-in-vscode-jump-to-definition

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I enabled the following options in my C# plugin for VSCode. Thanks for the pointer, Karl-Johan Sj?gren.

csharp extension settings

decompilation roslyn analyzers

Now when I press F12 on transform.Rotate(Vector.forward) for example, decompilation support allows me to see

transform.Rotation

This is very beneficial and helps me understand the how Unity handles rotations in different spaces. Also I can begin to understand complex Quaternion.Euler knowing how the familiar translate.Rotate uses it internally. The same is true for things like transform.Translate

transform.Translate

For example, if I didn't know I could directly manipulate position before, now I know transform.Translate is a means of doing just that. Being able to get this information at the click of a single button is a game-changer when you compare it to the alternative of alt-tabbing to your browser and doing a text-based search, spending minutes navigating to a specific section of code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...