question

amazdeh avatar image
amazdeh asked

How to use PlayFab Admin API in unity editor scripts

I want to use Admin API to upload my game servers and do other stuff in my config, I have to use editor scripting since I want to run this on unity cloud build too , Currently it seems the API relies on a GameObject and Coroutines to be able to run and execute my callbacks.

Is there any way I can utilize the unity SDK in editor scripts instead of having to write my own code to interact with the Web Service?

10 |1200

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

1 Answer

·
marcowilliamspf avatar image
marcowilliamspf answered

We don't currently have all the Admin API's part of the Editor extensions. However, that doesn't mean you can't add them in yourself.

Take a look at the class in PlayFabEditorExtensions/Editor/Scripts/PlayFabEditorSDK/PlayFabEditorApi.cs and see how we are utilizing existing admin api calls.

Next you would want to make your own class and namespace it PlayFab.Editor. Create a class and add static methods in the same or similar way that we have added admin api's.

See: UpdateCloudScript method as an example.

        public static void UpdateCloudScript(UpdateCloudScriptRequest request, Action<UpdateCloudScriptResult> resultCb, Action<EditorModels.PlayFabError> errorCb)
        {
            var titleId = PlayFabEditorDataService.envDetails.selectedTitleId;
            var apiEndpoint = String.Format("https://{0}{1}", titleId, PlayFabEditorHelper.TITLE_ENDPOINT);
            PlayFabEditorHttp.MakeApiCall<UpdateCloudScriptRequest, UpdateCloudScriptResult>("/Admin/UpdateCloudScript", apiEndpoint, request, resultCb, errorCb);
        }
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.