question

Minami avatar image
Minami asked

Unity + C# SDK : LocalAPIServer cannot be specified for local debugging of Cloudscript using Azure Functions

Hello!
I am using the C# SDK with Unity.

I followed the docs and tried to specify the LocalApiServer in playfab.local.settings.json, but it didn't work.
https://docs.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript-af/local-debugging-for-cloudscript-using-azure-functions

If you look at the SDK code, the code to get playfab.local.settings.json is written in `#if NET45 || NETSTANDARD2_0`. I need to add `NET_STANDARD_2_0` in order for it to work in Unity. Can you please modify the SDK?
https://github.com/PlayFab/CSharpSDK/blob/master/PlayFabSDK/source/PlayFabSettings.cs#L61

Also, as a workaround, I'm specifying the LocalApiServer directly in the code instead of using playfab.local.settings.json. It would be nice if there is an explanation in the docs on how to do this.

`PlayFabSettings.LocalApiServer = "http://localhost:7071/api/";`

Thank you.

sdksCloudScript
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

Firstly, this repo you mentioned in the question just applies to PlayFab C# SDK. If you want to implement the local debug in Unity, please refer to the repository of Unity SDK. In Unity, this file -- playfab.local.settings.json is handled here. So, you needn’t meet the condition “#if NET45 || NETSTANDARD2_0”. The default Unity settings would work fine.

Besides, have you referred to this repository -- pf-af-devfuncs to write your Azure Function? The default Azure Function local debug requires the URL of your local API server is “http://localhost:7071/api/CloudScript/ExecuteFunction”. If not, the API call ExecuteFunction may return “404 not found.” This Azure Function example set the route -- "CloudScript/ExecuteFunction" in the function definition, so it can work fine.

publicstaticasyncTask<HttpResponseMessage> ExecuteFunction( [HttpTrigger(AuthorizationLevel.Function,"post", Route ="CloudScript/ExecuteFunction")] HttpRequestrequest,ILoggerlog) {}

If you want to let the doc work, you would need to add this to your custom function too.

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.

Minami avatar image Minami commented ·

Thanks for the reply.

I know that Unity SDK and C# SDK are two different things.
I also understand the contents of pf-af-devfuncs.

I am using C# SDK in my Unity project because I want to make API calls with async/await.

Since the C# SDK works fine in Unity, I thought it would be nice if it could also work for local debugging of Cloud Script, so I requested it.

I would be happy if you would consider it.

Thank you.

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Minami commented ·

Hi, @Minami

  1. In terms of SDK issue, please feel free to send a thread on the Feature Request forum -- https://community.playfab.com/spaces/24/index.html. For now, for your personal requirement, I suggest modifying the source code on your project first.
  2. Is the 2nd question you cannot find the local.settings.json file? It is located at the Azure Function Project, and is a file generated automatically when creating the project. If you cannot find this file, please create one on your own.
1 Like 1 ·
shirao avatar image
shirao answered

%HOMEPATH%\AppData\Local\Temp\playfab.local.settings.json を

下記のように作成する

{ "LocalApiServer": "http://localhost:7071/api/" }

このパスは、環境変数 TEMP で調整可能です。

https://docs.microsoft.com/ja-jp/gaming/playfab/features/automation/cloudscript-af/local-debugging-for-cloudscript-using-azure-functions

CSharpSDK の方では確認していませんが、参考までに。

10 |1200

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

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.