Esempio n. 1
0
    public void CreateBuildWithCustomContainer(BuildBundleID identity)
    {
        ShowLoader();
        try {
            PortID[]   configuredPorts   = portButton.transform.parent.GetComponentsInChildren <PortID>(false);
            RegionID[] configuredRegions = regionButton.transform.parent.GetComponentsInChildren <RegionID>(false);

            if (configuredPorts.Length == 0)
            {
                Inform("Error: Ports cannot be empty! Please add a port.");
                return;
            }

            if (configuredRegions.Length == 0)
            {
                Inform("Error: Regions cannot be empty! Please add a region.");
                return;
            }

            List <Port> portList = new List <Port>();
            List <BuildRegionParams> regionList = new List <BuildRegionParams>();

            foreach (var port in configuredPorts)
            {
                portList.Add(port.portIDParams);
            }

            foreach (var region in configuredRegions)
            {
                regionList.Add(region.regionIDParams);
            }

            PlayFabMultiplayerAPI.CreateBuildWithCustomContainer(new CreateBuildWithCustomContainerRequest {
                BuildName               = identity.buildName.text,
                ContainerFlavor         = GetEnumValue <ContainerFlavor>(identity.containerFlavor.options[identity.containerFlavor.value].text),
                ContainerImageReference = new ContainerImageReference {
                    ImageName = identity.containerName.text,
                    Tag       = identity.containerTag.text
                },
                ContainerRunCommand         = "echo \"Server is being allocated...\" >> /data/GameLogs/Server.log",
                MultiplayerServerCountPerVm = int.Parse(identity.serverCountPerVm.text),
                VmSize = GetEnumValue <AzureVmSize>(identity.vmSize.options[identity.vmSize.value].text),


                Ports = portList,
                RegionConfigurations = regionList
            },
                                                                 result => {
                Debug.Log("CREATE BUILD OK: " + result.ToJson());
                buildID.gameObject.SetActive(false);
                InformURL("Build Created Successfully!\n\nBuild ID:\n" + result.BuildId,
                          string.Format("https://developer.playfab.com/en-US/{0}/multiplayer/server/builds", PlayFabSettings.TitleId));
            },
                                                                 error => {
                Debug.LogError("CREATE BUILD FAILURE: " + error.ToString());
                Inform("Build Creation Failure!\n\n" + error.ErrorMessage);
            });
        } catch (System.Exception e) {
            Inform(e.Message);
        }
    }