question

Hancu David avatar image
Hancu David asked

Unity and Playfab error,Playfab and Unity errors

I installed the unitysdk and unityeditorextensions packages to my unity project. When I open the script in visual studio, I get this error:

The type or namespace name 'PlayFab' could not be found (are you missing a using directive or an assembly reference?)

I wrote using Playfab; at the beginning, that's where I get this error. The code works and it does what it is supposed to do.

,

I installed the unitysdk.unitypackage and the editor extensions package to my unity project. When I open my script with visual studio, I get this error:
The type or namespace name 'PlayFab' could not be found (are you missing a using directive or an assembly reference?)

The code works as expected, the only problem is that I get these errors in visual studio.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sarah Zhang avatar image
Sarah Zhang answered

You can try to navigate to Visual Studio->[File]->[Move Assets\XXXX\XXXX.cs into], then choose the [Assembly-CSharp] in the menu, to fix such issues temporarily.

Sometimes the script files in the Unity projects cannot be linked to correct .net projects in Visual Studio. The possible reason that causes this issue is you have not set the Visual Studio as the External Script Editor for Unity. You can try to navigate to Unity->[Editor]->[Preferences...]->[External Tools], then choose the Visual Studio as the External Script Editor to set it.

More advanced problems about Unity and its External Script Editor, please navigate to the Unity developer forum for professional supports.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hancu David avatar image Hancu David commented ·

@Sarah Zhang I still get the errors.

0 Likes 0 ·
Hancu David avatar image Hancu David commented ·

I am still getting the errors @Sarah Zhang, can you help me?

0 Likes 0 ·
Tobias Lint avatar image
Tobias Lint answered

@Hancu David

I am working with Visual Studio Code as External Script Editor and was having this error multiple times. By settings this in Unity Preferences it solved it for me.

I am not sure when Unity added this setting. I am using Unity 2020.3.11f1


Maybe this will help somebody ;)

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Tobias Lint avatar image Tobias Lint commented ·

Sorry somehow the screenshot was not uploaded.

1 Like 1 ·
capture.jpg (97.8 KiB)

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.