Use UGC for player presets
注釈:本資料はAI技術を用いて翻訳されています。
概要
User Generated Content (UGC) は、プレイヤーが作成したゲーム内コンテンツを管理するサービスです。UGC は、既存の顧客のエンゲージメント、リテンション、ロイヤルティを高めるだけでなく、新規顧客を惹きつけるための強力な手段となります。UGC の形式はゲームによってさまざまで、その可能性は無限大です。例としては、ゲームキャラクターのカスタマイズ、乗り物の色のカスタマイズ、武器への新しい要素の追加、カスタムマップの作成などが挙げられます。
多くのゲームでは、プレイヤーコンテンツに対して高度なカスタマイズを実装しています。コンテンツをカスタマイズできるようにすると、プレイヤーは自分の個性、好み、スタイルを反映したコンテンツを作成できるため、ゲーム世界への没入感とエンゲージメントが高まります。また、プレイヤーが自分のコンテンツからプリセットを作成して他のプレイヤーと共有できる場合は、プレイヤー間の交流やコミュニティ形成を促進することもできます。プレイヤーが自分のコンテンツを通じて創造性やアイデンティティを表現できるようにすることで、開発者は熱心なファン層を築き、ゲームに関する好意的な口コミを生み出すことができます。
この記事では、UGC サービスを使用してプレイヤー生成コンテンツを保存し、ゲームクライアント内に表示し、ゲームのユースケースに応じて利用する方法を説明します。
前提条件
以下へのアクセスが必要です。
- AccelByte Gaming Services (AGS) Admin Portal
- AGS Unreal または Unity SDK
- 参考用の AGS UGC API ドキュメント
プレイヤーコンテンツを保存するチャンネルを作成する
UGC サービスは、チャンネルに基づいてプレイヤーコンテンツを管理します。チャンネルは、プレイヤーのコンテンツを分類するために使用する汎用的なエンティティです。チャンネルを使用すると、リージョン、言語、ビルドバージョン、パッチ、コンテンツカテゴリなど、ゲームシナリオに必要な任意の基準でコンテンツをグループ化できます。チャンネルはハードコードすることも、プレイヤー自身が管理できるようにすることもできます。
SDK を使用してチャンネルを作成する
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient();
FString ChannelName = "YourChannelName";
ApiClient->UGC.CreateChannel(ChannelName, THandler<FAccelByteModelsUGCChannelResponse>::CreateLambda([](const FAccelByteModelsUGCChannelResponse& Result)
{
// Do something if CreateV2Channel succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CreateV2Channel fails
}));
string channelName = "YourChannelName";
UGC ugc = AccelByteSDK.GetClientRegistry().GetApi().GetUgc();
ugc.CreateChannel(channelName, result =>
{
if (result.IsError)
{
// Do something if CreateChannel fails
Debug.Log($"Error CreateChannel, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Get channel ID
string channelId = result.Value.id;
// Do something if CreateChannel succeeds
});
string channelName = "MyChannelName";
string userId = "<user-id>";
var response = sdk.Ugc.PublicChannel.PublicCreateChannelOp
.Execute(new ModelsPublicChannelRequest()
{
Name = channelName
}, sdk.Namespace, userId);
if (response != null)
{
string channelId = response.Id!;
// Do something if successful
}
publicChannelService := &ugc.PublicChannelService{
Client: factory.NewUgcClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
channelName := "mychannelname"
body := ugcclientmodels.ModelsPublicChannelRequest {
Name: &channelName,
}
namespace := "mygame"
userId := "myuserid"
input := &public_channel.PublicCreateChannelParams{
Body: &body,
Namespace: namespace,
UserID: userId,
}
result, err := publicChannelService.PublicCreateChannelShort(input)
String channelName = "MyChannelName";
String userId = "<user-id>";
ModelsChannelResponse response;
try {
ModelsPublicChannelRequest reqBody = ModelsPublicChannelRequest.builder()
.name(channelName)
.build();
response = publicChannelWrapper.publicCreateChannel(PublicCreateChannel.builder()
.namespace("<namespace>")
.body(reqBody)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if successful
}
import accelbyte_py_sdk.api.ugc as ugc_service
import accelbyte_py_sdk.api.ugc.models as ugc_models
result, error = ugc_service.public_create_channel(
body=ugc_models.ModelsPublicChannelRequest()
.with_name("YourChannelName"),
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
SDK を使用してプレイヤーチャンネルのリストを取得する
この関数を使用して、プレイヤーチャンネルのリストを取得できます。
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient();
FString UserId = "YourUserId";
int32 Limit = 1000;
int32 Offset = 0;
FString ChannelName = "YourChannelName";
ApiClient->UGC.GetChannels(UserId, THandler<FAccelByteModelsUGCChannelsPagingResponse>::CreateLambda([](const FAccelByteModelsUGCChannelsPagingResponse& Result)
{
// Do something if GetChannels succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetChannels fails
}), Limit, Offset, ChannelName);
string userId = "YourUserId";
string channelName = "YourChannelName";
int limit = 1000;
int offset = 0;
UGC ugc = AccelByteSDK.GetClientRegistry().GetApi().GetUgc();
ugc.GetChannels(userId, result =>
{
if (result.IsError)
{
// Do something if GetChannels fails
Debug.Log($"Error GetChannels, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if GetChannels succeeds
}, offset, limit, channelName);
string channelName = "MyChannelName";
string userId = "<user-id>";
var response = sdk.Ugc.PublicChannel.GetChannelsOp
.SetName(channelName)
.SetOffset(0)
.SetLimit(1000)
.Execute(sdk.Namespace, userId);
if (response != null)
{
// Do something if successful
}
publicChannelService := &ugc.PublicChannelService{
Client: factory.NewUgcClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
userId := "myuserid"
limit := int64(1000)
name := "mychannelname"
offset := int64(0)
input := &public_channel.GetChannelsParams{
Namespace: namespace,
UserID: userId,
Limit: &limit,
Name: &name,
Offset: &offset,
}
result, err := publicChannelService.GetChannelsShort(input)
final PublicChannel publicChannelWrapper = new PublicChannel(sdk);
String channelName = "MyChannelName";
String userId = "<user-id>";
ModelsPaginatedGetChannelResponse response;
try {
response = publicChannelWrapper.getChannels(GetChannels.builder()
.namespace("<namespace>")
.userId(userId)
.name(channelName)
.offset(0)
.limit(1000)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if successful
}
import accelbyte_py_sdk.api.ugc as ugc_service
result, error = ugc_service.get_channels(
user_id="********************************",
limit=1000,
name="YourChannelName",
offset=0,
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
UGC にプレイヤーコンテンツを保存する
プレイヤーコンテンツをプリセットとして UGC サービスに保存するには、プレイヤーコンテンツに適用したすべてのカスタマイズオプションを含むファイルを作成する必要があります。このファイルに、プレイヤーコンテンツに関する情報が保存されます。
UGC サービスでプレイヤーコンテンツを作成するには、2つのステップが必要です。まず、ファイルをアップロードするための署名付き URL をサービスにリクエストします。このステップでは、プレイヤーコンテンツの名前、タグ、タイプ、サブタイプなどの基本的なメタデータも指定できます。次に、その署名付き URL を使用してファイルをサービスにアップロードします。
Client SDK を使用して署名付き URL を取得する
SDK を使用して署名付き URL を取得する
この関数を使用すると、プレイヤーコンテンツのメタデータを設定し、プレイヤーコンテンツをクラウドストレージにアップロードするための署名付き URL を取得できます。
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient();
FString ChannelId = "YourChannelId";
FAccelByteModelsCreateUGCRequestV2 UGCRequest = {};
UGCRequest.ContentType = "PNG";
UGCRequest.FileExtension = "PNG";
UGCRequest.Name = "UGC Integration UE4";
UGCRequest.Type = "UGC Type";
UGCRequest.SubType = "UGC SubType";
UGCRequest.Tags = { "UGC Tag1", "UGC Tag2"};
ApiClient->UGC.CreateV2Content(ChannelId, UGCRequest, THandler<FAccelByteModelsUGCCreateUGCResponseV2>::CreateLambda([](const FAccelByteModelsUGCCreateUGCResponseV2& Result)
{
// Do something if CreateV2Content succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CreateV2Content fails
}));
string channelId = "YourChannelId";
var createRequest = new Models.CreateUGCRequestV2()
{
ContentType = "png",
FileExtension = "png",
Name = "UGC Integration Unity",
Type = "UGC Type",
Tags = new[] { "UGC Tag1", "UGC Tag2" },
CustomAttributes = new System.Collections.Generic.Dictionary<string, object>()
};
var ugc = AccelByteSDK.GetClientRegistry().GetApi().GetUgc();
ugc.CreateContentV2(channelId, createRequest, result =>
{
if (result.IsError)
{
// Do something if CreateContentV2 fails
Debug.Log($"Error CreateContentV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
string presignedUrl = result.Value.PayloadUrl[0].url; // you can get presigned url from the result
// Do something if CreateContentV2 succeeds
});
string channelId = "<YourUGCChannelId>";
string userId = "<user-id>";
var response = sdk.Ugc.PublicContentV2.PublicCreateContentV2Op
.Execute(new ModelsContentRequestV2()
{
ContentType = "application/octet-stream",
FileExtension = "bin",
Name = "Custom sports body",
Type = "Vehicle",
Tags = new List<string>() { "Red", "Sporty" },
CustomAttributes = new Dictionary<string, object>()
}, channelId, sdk.Namespace, userId);
if (response != null)
{
string preSignedUrl = response.PayloadURL![0].Url!;
}
publicChannelService := &ugc.PublicChannelService{
Client: factory.NewUgcClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
userId := "myuserid"
limit := int64(1000)
name := "mychannelname"
offset := int64(0)
input := &public_channel.GetChannelsParams{
Namespace: namespace,
UserID: userId,
Limit: &limit,
Name: &name,
Offset: &offset,
}
result, err := publicChannelService.GetChannelsShort(input)
final PublicContentV2 publicContentV2Wrapper = new PublicContentV2(sdk);
String channelId = "<YourUGCChannelId>";
String userId = "<user-id>";
ModelsCreateContentResponseV2 response;
try {
ModelsContentRequestV2 reqBody = ModelsContentRequestV2.builder()
.contentType("application/octet-stream")
.fileExtension("bin")
.name("Custom sports body")
.type("Vehicle")
.tags(Arrays.asList("Red", "Sporty"))
.customAttributes(Collections.emptyMap())
.build();
response = publicContentV2Wrapper.publicCreateContentV2(PublicCreateContentV2.builder()
.namespace("<namespace>")
.userId(userId)
.channelId(channelId)
.body(reqBody)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response != null && response.getPayloadURL() != null && response.getPayloadURL().get(0).getUrl() != null) {
// You can get presigned url from the result
String preSignedUrl = response.getPayloadURL().get(0).getUrl();
}
import accelbyte_py_sdk.api.ugc as ugc_service
import accelbyte_py_sdk.api.ugc.models as ugc_models
result, error = ugc_service.public_create_content_v2(
body=ugc_models.ModelsContentRequestV2()
.with_content_type("PNG")
.with_file_extension("PNG")
.with_name("UGC Integration Python")
.with_type("UGC Type")
.with_sub_type("UGC Subtype")
.with_tags(["UGC Tag1", "UGC Tag2"]),
channel_id="YourChannelId",
user_id="********************************",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
SDK を使用してプレイヤーコンテンツファイルをアップロードする
この関数には署名付き URL が必要です。Client SDK を使用して署名付き URL を取得するを参照してください。
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FString Url = "PayloadUGCUrlToUpload";
TArray<uint8> DataUpload = { 106, 35, 171, 106, 138, 197, 77, 94, 182, 18, 99, 9, 245, 110, 45, 197, 22, 35};
FAccelByteNetUtilities::UploadTo(Url, DataUpload, FHttpRequestProgressDelegate::CreateLambda([](const FHttpRequestPtr& Request, int32 BytesSent, int32 BytesReceived)
{
// Do something if UploadTo still in progress successful
}),FVoidHandler::CreateLambda([]()
{
// Do something if UploadTo succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadTo fails
}));
string url = "YourPresignedUrl";
byte[] yourDataToUpload;
string contentType = "FileContentType";
var uploadOptionalParameters = new UploadBinaryOptionalParameters()
{
ContentType = contentType
};
AccelByteNetUtilities.UploadBinaryTo(url, yourDataToUpload, uploadOptionalParameters, result =>
{
if (result.IsError)
{
// Do something if UploadTo fails
Debug.Log($"Error UploadTo, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if UploadTo succeeds
});
string presignedUrlToUpload = "<url>"; //from PublicCreateContentV2Op
byte[] dataToUpload = new byte[] { 10, 30, 40, 50, 60, 70, 80 };
var isSuccess = sdk.UploadBinaryData(presignedUrlToUpload, dataToUpload, "application/octet-stream");
if (isSuccess)
{
// Do something if upload succeeds
}
presignedURL := "PayloadUGCUrlToUpload"
filePath := "FilePath"
resp, err := utils.UploadBinaryFile(presignedURL, token, filePath)
if err != nil {
// Do something if an error occurs
}
String presignedUrlToUpload = "<url>"; //from PublicCreateContentV2Op
byte[] dataToUpload = new byte[] { 10, 30, 40, 50, 60, 70, 80 };
final boolean isSuccess = sdk.uploadBinaryData(presignedUrlToUpload, dataToUpload, "application/octet-stream");
if (isSuccess)
{
// Do something if upload succeeds
}
from accelbyte_py_sdk.core import get_http_client
# data_upload = ...
url = "PayloadUGCUrlToUpload"
response = get_http_client().upload_binary_data(
url=url,
data=data_upload,
headers={
"Content-Type": "application/octet-stream",
}
)
プレイヤーコンテンツにスクリーンショットを追加する
プレイヤーコンテンツファイルをより魅力的で分かりやすくする方法の1つは、ゲーム内での見た目を示すスクリーンショットを追加することです。スクリーンショットを使えば、プリセットファイルで作り出した視覚効果やディテールを伝えることができます。
SDK を使用してスクリーンショットアップロード用の署名付き URL を取得する
この関数を使用して、特定のプレイヤーコンテンツのスクリーンショットをアップロードするための署名付き URL を取得できます。
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient();
FString ContentId = "YourContentId";
FString UserId = "UserId";
FAccelByteModelsUGCUploadScreenshotV2 Screenshot;
Screenshot.Description = "Screenshot Test Description";
Screenshot.ContentType = "png";
Screenshot.FileExtension = "png";
FAccelByteModelsUGCUploadScreenshotsRequestV2 ScreenshotsRequest = {};
ScreenshotsRequest.Screenshots = { Screenshot };
ApiClient->UGC.UploadV2ScreenshotContent(ContentId, ScreenshotsRequest, THandler<FAccelByteModelsUGCUpdateContentScreenshotResponse>::CreateLambda([](const FAccelByteModelsUGCUpdateContentScreenshotResponse& Result)
{
// Do something if UploadV2ScreenshotContent succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadV2ScreenshotContent fails
}));
string contentId = "YourContentId";
ScreenshotRequest screenshotRequest = new ScreenshotRequest()
{
description = "UGC Screenshot Description",
contentType = "png",
fileExtension = UGCFileExtension.PNG
};
ScreenshotsRequest screenshotsRequest = new ScreenshotsRequest()
{
screenshots = new[] { screenshotRequest }
};
UGC ugc = AccelByteSDK.GetClientRegistry().GetApi().GetUgc();
ugc.UploadContentScreenshotV2(contentId, screenshotsRequest, result =>
{
if (result.IsError)
{
// Do something if UploadContentScreenshotV2 fails
Debug.Log($"Error UploadContentScreenshotV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if UploadContentScreenshotV2 succeeds
string presignedUrl = result.Value.Screenshots[0].Url;
});
string contentId = "<YourUGCContentId>";
string userId = "<user-id>";
var response = sdk.Ugc.PublicContentV2.UploadContentScreenshotV2Op
.Execute(new ModelsCreateScreenshotRequest()
{
Screenshots = new List<ModelsCreateScreenshotRequestItem>()
{
new ModelsCreateScreenshotRequestItem()
{
Description = "UGC screenshot description",
FileExtension = "PNG"
}
}
}, contentId, sdk.Namespace, userId);
if (response != null)
{
string preSignedUrl = response.Screenshots![0].Url!;
}
publicContentV2Service := &ugc.PublicContentV2Service{
Client: factory.NewUgcClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
description := "UGC screenshot description"
fileExtension := "PNG"
item := ugcclientmodels.ModelsCreateScreenshotRequestItem {
Description: &description,
FileExtension: &fileExtension,
}
body := ugcclientmodels.ModelsCreateScreenshotRequest {
Screenshots: []*ugcclientmodels.ModelsCreateScreenshotRequestItem {
&item,
},
}
contentId := "mycontentid"
namespace := "mygame"
userId := "myuserid"
input := &public_content_v2.UploadContentScreenshotV2Params{
Body: &body,
ContentID: contentId,
Namespace: namespace,
UserID: userId,
}
result, err := publicContentV2Service.UploadContentScreenshotV2Short(input)
String contentId = "<YourUGCContentId>";
String userId = "<user-id>";
ModelsCreateScreenshotResponse response;
try {
ModelsCreateScreenshotRequest reqBody = ModelsCreateScreenshotRequest.builder()
.screenshots(Arrays.asList(ModelsCreateScreenshotRequestItem.builder()
.description("UGC screenshot description")
.fileExtension("PNG")
.build())
).build();
response = publicContentV2Wrapper.uploadContentScreenshotV2(UploadContentScreenshotV2.builder()
.namespace("<namespace>")
.userId(userId)
.contentId(contentId)
.body(reqBody)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response != null && response.getScreenshots() != null && response.getScreenshots().get(0).getUrl() != null) {
String preSignedUrl = response.getScreenshots().get(0).getUrl();
}
import accelbyte_py_sdk.api.ugc as ugc_service
import accelbyte_py_sdk.api.ugc.models as ugc_models
result, error = ugc_service.upload_content_screenshot_v2(
body=ugc_models.ModelsCreateScreenshotRequest()
.with_screenshots([
ugc_models.ModelsCreateScreenshotRequestItem()
.with_description("Screenshot Test Description")
.with_content_type("png")
.with_file_extension("png")
]),
content_id="YourContentId",
user_id="********************************",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
SDK を使用してスクリーンショットをアップロードする
特定のプレイヤーコンテンツのスクリーンショットをクラウドストレージにアップロードするには、この関数を使用します。
この関数には署名付き URL が必要です。Client SDK を使用して署名付き URL を取得するを参照してください。
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FString Url = "PayloadScreenshotUrlToUpload";
TArray<uint8> DataUpload = { 35, 171, 106, 138, 197, 77, 94, 182, 18, 99, 9, 245, 110, 45, 197, 35};
FAccelByteNetUtilities::UploadTo(Url, DataUpload, FHttpRequestProgressDelegate::CreateLambda([](const FHttpRequestPtr& Request, int32 BytesSent, int32 BytesReceived)
{
// Do something if UploadTo still in progress successful
}),FVoidHandler::CreateLambda([]()
{
// Do something if UploadTo succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadTo fails
}));
プレイヤーコンテンツファイルのアップロードと同じコード実装に従ってください。
string presignedUrlToUpload = "<url>"; //from UploadContentScreenshotV2Op
byte[] dataToUpload = new byte[] { 35, 171, 106, 138, 197, 77, 94, 182, 18, 99, 9, 245, 110, 45, 197, 35 };
var isSuccess = sdk.UploadBinaryData(presignedUrlToUpload, dataToUpload, "application/octet-stream");
if (isSuccess)
{
// Do something if upload succeeds
}
presignedURL := "PayloadScreenshotUrlToUpload"
filePath := "FilePath"
resp, err := utils.UploadBinaryFile(presignedURL, token, filePath)
if err != nil {
// Do something if an error occurs
}
String presignedUrlToUpload = "<url>"; //from UploadContentScreenshotV2Op
byte[] dataToUpload = new byte[] { 35, 171, 106, 138, 197, 77, 94, 182, 18, 99, 9, 245, 110, 45, 197, 35 };
final boolean isSuccess = sdk.uploadBinaryData(presignedUrlToUpload, dataToUpload, "application/octet-stream");
if (isSuccess)
{
// Do something if upload succeeds
}
from accelbyte_py_sdk.core import get_http_client
# data_upload = ...
url = "PayloadScreenshotUrlToUpload"
response = get_http_client().upload_binary_data(
url=url,
data=data_upload,
headers={
"Content-Type": "application/octet-stream",
}
)
シェアコードでプレイヤーコンテンツを表示する
プレイヤーがプレイヤーコンテンツを作成すると、UGC サービスはそのコンテンツに固有のシェアコードを生成します。プレイヤーはそのシェアコードを他のプレイヤーと共有して、自分の作品を披露したり、試してもらうよう誘ったりすることができます。他のプレイヤーはシェアコードを使ってプリセットの詳細にアクセスできます。また、そのプリセットを自分のゲームに適用したり、好みに応じて変更したりすることもできます。
SDK を使用してシェアコードでプレイヤーコンテンツを表示する
以下の例では、シェアコードを使用してプレイヤーコンテンツを取得する方法を示します。
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient();
FString ShareCode = "YourUGCShareCode";
ApiClient->UGC.GetV2ContentByShareCode(ShareCode, THandler<FAccelByteModelsUGCContentResponseV2>::CreateLambda([](const FAccelByteModelsUGCContentResponseV2& Result)
{
// Do something if GetV2ContentByShareCode succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetV2ContentByShareCode fails
}));
string shareCode = "YourUGCShareCode";
UGC ugc = AccelByteSDK.GetClientRegistry().GetApi().GetUgc();
ugc.GetContentByShareCodeV2(shareCode, result =>
{
if (result.IsError)
{
// Do something if GetContentByShareCodeV2 fails
Debug.Log($"Error GetContentByShareCodeV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if GetContentByShareCodeV2 succeeds
});
string shareCode = "<YourUGCShareCode>";
var response = sdk.Ugc.PublicContentV2.PublicGetContentByShareCodeV2Op
.Execute(sdk.Namespace, shareCode);
if (response != null)
{
// Do something if successful
}
publicContentV2Service := &ugc.PublicContentV2Service{
Client: factory.NewUgcClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
namespace := "mygame"
shareCode := "mysharecode"
input := &public_content_v2.PublicGetContentByShareCodeV2Params{
Namespace: namespace,
ShareCode: shareCode,
}
result, err := publicContentV2Service.PublicGetContentByShareCodeV2Short(input)
final PublicContentV2 publicContentV2Wrapper = new PublicContentV2(sdk);
String shareCode = "<YourUGCShareCode>";
ModelsContentDownloadResponseV2 response;
try {
response = publicContentV2Wrapper.publicGetContentByShareCodeV2(PublicGetContentByShareCodeV2.builder()
.namespace("<namespace>")
.shareCode(shareCode)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if successful
}
import accelbyte_py_sdk.api.ugc as ugc_service
result, error = ugc_service.public_get_content_by_share_code_v2(
share_code="YourUGCShareCode",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
プレイヤーコンテンツを変更する
プレイヤーコンテンツを変更する際、プレイヤーはプレイヤーコンテンツのメタデータのみ、またはプリセットファイルのみを更新できます。
UGC サービスでプリセットファイルを変更するには、3つのステップが必要です。まず、新しいファイルをアップロードするための署名付き URL をサービスにリクエストします。次に、その署名付き URL を使用してファイルをサービスにアップロードします。最後に、新しいファイルの場所を更新して変更をコミットします。
SDK を使用してプレイヤーコンテンツのメタデータを更新する
プレイヤーコンテンツのメタデータを更新するには、この関数を使用します。
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient();
FString ChannelId = "YourChannelId";
FString ContentId = "YourContentId";
FAccelByteModelsModifyUGCRequestV2 ModifyRequest = {};
ModifyRequest.Name = "Updated UGC Integration UE4";
ModifyRequest.Type = "Updated UGC Type";
ModifyRequest.SubType = "Updated UGC SubType";
ModifyRequest.Tags = { "Updated UGC Tag1", "Updated UGC Tag2"};
ApiClient->UGC.ModifyV2Content(ChannelId, ContentId, ModifyRequest, THandler<FAccelByteModelsUGCModifyUGCResponseV2>::CreateLambda([](const FAccelByteModelsUGCModifyUGCResponseV2& Result)
{
// Do something if ModifyV2Content succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if ModifyV2Content fails
}));
string channelId = "YourChannelId";
string contentId = "YourContentId";
ModifyUGCRequestV2 ModifyRequest = new ModifyUGCRequestV2
{
Name = "Updated UGC Integration Unity",
Type = "Updated UGC Type",
Tags = new[] { "Updated UGC Tag1", "Updated UGC Tag2" },
CustomAttributes = new Dictionary<string, object>()
};
UGC ugc = AccelByteSDK.GetClientRegistry().GetApi().GetUgc();
ugc.ModifyContentV2(channelId, contentId, ModifyRequest, result =>
{
if (result.IsError)
{
// Do something if ModifyContentV2 fails
Debug.Log($"Error ModifyContentV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if ModifyContentV2 succeeds
});
string channelId = "<YourUGCChannelId>";
string contentId = "<YourUGCContentId>";
string userId = "<user-id>";
var response = sdk.Ugc.PublicContentV2.PublicUpdateContentV2Op
.Execute(new ModelsUpdateContentRequestV2()
{
Name = "Custom sports body",
Type = "Vehicle",
SubType = "Body",
Tags = new List<string>() { "Blue", "Body", "Sporty" },
CustomAttributes = new Dictionary<string, object>()
}, channelId, contentId, sdk.Namespace, userId);
if (response != null)
{
// Do something if successful
}
publicContentV2Service := &ugc.PublicContentV2Service{
Client: factory.NewUgcClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
body := ugcclientmodels.ModelsUpdateContentRequestV2 {
Name: "Custom sports body",
Type: "Vehicle",
SubType: "Body",
Tags: []string{"Blue","Body","Sporty"},
CustomAttributes: map[string]interface{}{},
}
channelId := "mychannelid"
contentId := "mycontentid"
namespace := "mygame"
userId := "myuserid"
input := &public_content_v2.PublicUpdateContentV2Params{
Body: &body,
ChannelID: channelId,
ContentID: contentId,
Namespace: namespace,
UserID: userId,
}
result, err := publicContentV2Service.PublicUpdateContentV2Short(input)
final PublicContentV2 publicContentV2Wrapper = new PublicContentV2(sdk);
String channelId = "<YourUGCChannelId>";
String contentId = "<YourUGCContentId>";
String userId = "<user-id>";
ModelsUpdateContentResponseV2 response;
try {
ModelsUpdateContentRequestV2 reqBody = ModelsUpdateContentRequestV2.builder()
.name("Custom sports body")
.type("Vehicle")
.subType("Body")
.tags(Arrays.asList("Blue", "Body", "Sporty"))
.customAttributes(Collections.emptyMap())
.build();
response = publicContentV2Wrapper.publicUpdateContentV2(PublicUpdateContentV2.builder()
.namespace("<namespace>")
.userId(userId)
.channelId(channelId)
.contentId(contentId)
.body(reqBody)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if successful
}
import accelbyte_py_sdk.api.ugc as ugc_service
import accelbyte_py_sdk.api.ugc.models as ugc_models
result, error = ugc_service.public_update_content_v2(
body=ugc_models.ModelsUpdateContentRequestV2()
.with_name("Updated UGC Integration Python")
.with_type("Updated UGC Type")
.with_sub_type("Updated UGC Subtype")
.with_tags(["Updated UGC Tag1", "Updated UGC Tag2"]),
channel_id="YourChannelId",
content_id="YourContentId",
user_id="********************************",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
SDK を使用して署名付き URL をリクエストする
更新したプレイヤーコンテンツをクラウドストレージにアップロードするための署名付き URL を取得するには、この関数を使用します。
- Unreal Engine
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient();
FString ChannelId = "YourChannelId";
FString ContentId = "YourContentId";
FAccelByteModelsUploadContentURLRequestV2 UploadRequest = {};
UploadRequest.ContentType = "PNG";
UploadRequest.FileExtension = "PNG";
ApiClient->UGC.GenerateUploadContentURLV2(ChannelId, ContentId, UploadRequest, THandler<FAccelByteModelsUGCUploadContentURLResponseV2>::CreateLambda([](const FAccelByteModelsUGCUploadContentURLResponseV2& Result)
{
// Do something if GenerateUploadContentURLV2 succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GenerateUploadContentURLV2 fails
}));
string channelId = "<YourUGCChannelId>";
string contentId = "<YourUGCContentId>";
string userId = "<user-id>";
var response = sdk.Ugc.PublicContentV2.PublicGenerateContentUploadURLV2Op
.Execute(new ModelsGenerateContentUploadURLRequest()
{
ContentType = "PNG",
FileExtension = "PNG"
}, channelId, contentId, sdk.Namespace, userId);
if (response != null)
{
string preSignedUrl = response.Url!;
}
publicContentV2Service := &ugc.PublicContentV2Service{
Client: factory.NewUgcClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
body := ugcclientmodels.ModelsGenerateContentUploadURLRequest {
ContentType: "PNG",
FileExtension: "PNG",
}
channelId := "mychannelid"
contentId := "mycontentid"
namespace := "mygame"
userId := "myuserid"
input := &public_content_v2.PublicGenerateContentUploadURLV2Params{
Body: &body,
ChannelID: channelId,
ContentID: contentId,
Namespace: namespace,
UserID: userId,
}
result, err := publicContentV2Service.PublicGenerateContentUploadURLV2Short(input)
final PublicContentV2 publicContentV2Wrapper = new PublicContentV2(sdk);
String channelId = "<YourUGCChannelId>";
String contentId = "<YourUGCContentId>";
String userId = "<user-id>";
ModelsGenerateContentUploadURLResponse response;
try {
ModelsGenerateContentUploadURLRequest reqBody = ModelsGenerateContentUploadURLRequest.builder()
.contentType("PNG")
.fileExtension("PNG")
.build();
response = publicContentV2Wrapper.publicGenerateContentUploadURLV2(PublicGenerateContentUploadURLV2.builder()
.namespace("<namespace>")
.userId(userId)
.channelId(channelId)
.contentId(contentId)
.body(reqBody)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response != null && response.getUrl() != null)
{
String preSignedUrl = response.getUrl();
}
import accelbyte_py_sdk.api.ugc as ugc_service
import accelbyte_py_sdk.api.ugc.models as ugc_models
result, error = ugc_service.public_generate_content_upload_urlv2(
body=ugc_models.ModelsGenerateContentUploadURLRequest()
.with_content_type("PNG")
.with_file_extension("PNG"),
channel_id="YourChannelId",
content_id="YourContentId",
user_id="********************************",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
SDK を使用して更新したプレイヤーコンテンツファイルをアップロードする
この関数には署名付き URL が必要です。Client SDK を使用して署名付き URL を取得するを参照してください。
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FString Url = "PayloadUpdatedUGCUrlToUpload";
TArray<uint8> DataUpload = { 106, 35, 171, 106, 138, 197, 94, 182, 18, 99, 9, 245, 110, 45, 197, 35};
FAccelByteNetUtilities::UploadTo(Url, DataUpload, FHttpRequestProgressDelegate::CreateLambda([](const FHttpRequestPtr& Request, int32 BytesSent, int32 BytesReceived)
{
// Do something if UploadTo still in progress successful
}),FVoidHandler::CreateLambda([]()
{
// Do something if UploadTo succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadTo fails
}));
プレイヤーコンテンツファイルのアップロードと同じコード実装に従ってください。
string presignedUrlToUpload = "<url>"; //from PublicGenerateContentUploadURLV2Op
byte[] dataToUpload = new byte[] { 106, 35, 171, 106, 138, 197, 94, 182, 18, 99, 9, 245, 110, 45, 197, 35 };
var isSuccess = sdk.UploadBinaryData(presignedUrlToUpload, dataToUpload, "application/octet-stream");
if (isSuccess)
{
// Do something if upload succeeds
}
presignedURL := "PayloadUpdatedUGCUrlToUpload"
filePath := "FilePath"
resp, err := utils.UploadBinaryFile(presignedURL, token, filePath)
if err != nil {
// Do something if an error occurs
}
String presignedUrlToUpload = "<url>"; //from PublicGenerateContentUploadURLV2Op
byte[] dataToUpload = new byte[] { 106, 35, 171, 106, 138, 197, 94, 182, 18, 99, 9, 245, 110, 45, 197, 35 };
final boolean isSuccess = sdk.uploadBinaryData(presignedUrlToUpload, dataToUpload, "application/octet-stream");
if (isSuccess)
{
// Do something if upload succeeds
}
from accelbyte_py_sdk.core import get_http_client
# data_upload = ...
url = "PayloadUpdatedUGCUrlToUpload"
response = get_http_client().upload_binary_data(
url=url,
data=data_upload,
headers={
"Content-Type": "application/octet-stream",
}
)
SDK を使用してプレイヤーコンテンツファイルの場所を更新する
プレイヤーコンテンツファイルのアップロードが完了したら、次の関数を使用して変更をコミットし、新しいファイルの場所が反映されるようにします。
- Unreal Engine
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient();
FString ChannelId = "YourChannelId";
FString ContentId = "YourContentId";
FString FileExtension = "PNG";
FString S3Key = "YourContentS3Key";
ApiClient->UGC.UpdateContentFileLocationV2(ChannelId, ContentId, FileExtension, S3Key, THandler<FAccelByteModelsUGCUpdateContentFileLocationResponseV2>::CreateLambda([](const FAccelByteModelsUGCUpdateContentFileLocationResponseV2& Response)
{
// Do something if UpdateContentFileLocationV2 succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateContentFileLocationV2 fails
}));
string channelId = "<YourUGCChannelId>";
string contentId = "<YourUGCContentId>";
string userId = "<user-id>";
var response = sdk.Ugc.PublicContentV2.PublicUpdateContentFileLocationOp
.Execute(new ModelsUpdateFileLocationRequest()
{
FileExtension = "PNG",
FileLocation = "<YourContentS3Key>"
}, channelId, contentId, sdk.Namespace, userId);
if (response != null)
{
// Do something if successful
}
publicContentV2Service := &ugc.PublicContentV2Service{
Client: factory.NewUgcClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
fileLocation := "mycontents3key"
body := ugcclientmodels.ModelsUpdateFileLocationRequest {
FileExtension: "PNG",
FileLocation: &fileLocation,
}
channelId := "mychannelid"
contentId := "mycontentid"
namespace := "mygame"
userId := "myuserid"
input := &public_content_v2.PublicUpdateContentFileLocationParams{
Body: &body,
ChannelID: channelId,
ContentID: contentId,
Namespace: namespace,
UserID: userId,
}
result, err := publicContentV2Service.PublicUpdateContentFileLocationShort(input)
final PublicContentV2 publicContentV2Wrapper = new PublicContentV2(sdk);
String channelId = "<YourUGCChannelId>";
String contentId = "<YourUGCContentId>";
String userId = "<user-id>";
ModelsUpdateContentResponseV2 response;
try {
ModelsUpdateFileLocationRequest reqBody = ModelsUpdateFileLocationRequest.builder()
.fileExtension("PNG")
.fileLocation("<YourContentS3Key>")
.build();
response = publicContentV2Wrapper.publicUpdateContentFileLocation(PublicUpdateContentFileLocation.builder()
.namespace("<namespace>")
.userId(userId)
.channelId(channelId)
.contentId(contentId)
.body(reqBody)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if successful
}
import accelbyte_py_sdk.api.ugc as ugc_service
import accelbyte_py_sdk.api.ugc.models as ugc_models
result, error = ugc_service.public_update_content_file_location(
body=ugc_models.ModelsUpdateFileLocationRequest()
.with_file_location("YourContentS3Key")
.with_file_extension("PNG"),
channel_id="YourChannelId",
content_id="YourContentId",
user_id="********************************",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
プレイヤーコンテンツを削除する
Client SDK を使用してプレイヤーコンテンツを削除する
- Unreal Engine
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient();
FString ChannelId = "YourChannelId";
FString ContentId = "YourContentId";
ApiClient->UGC.DeleteV2Content(ChannelId, ContentId, FVoidHandler::CreateLambda([]()
{
// Do something if DeleteV2Content succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if DeleteV2Content fails
}));
string channelId = "YourChannelId";
string contentId = "YourContentId";
UGC ugc = AccelByteSDK.GetClientRegistry().GetApi().GetUgc();
ugc.DeleteContentV2(channelId, contentId, result =>
{
if (result.IsError)
{
// Do something if DeleteContentV2 fails
Debug.Log($"Error DeleteContentV2, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if DeleteContentV2 succeeds
});
string channelId = "<YourUGCChannelId>";
string contentId = "<YourUGCContentId>";
string userId = "<user-id>";
sdk.Ugc.PublicContentV2.PublicDeleteContentV2Op
.Execute(channelId, contentId, sdk.Namespace, userId);
publicContentV2Service := &ugc.PublicContentV2Service{
Client: factory.NewUgcClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
channelId := "mychannelid"
contentId := "mycontentid"
namespace := "mygame"
userId := "myuserid"
input := &public_content_v2.PublicDeleteContentV2Params{
ChannelID: channelId,
ContentID: contentId,
Namespace: namespace,
UserID: userId,
}
err := publicContentV2Service.PublicDeleteContentV2Short(input)
final PublicContentV2 publicContentV2Wrapper = new PublicContentV2(sdk);
String channelId = "<YourUGCChannelId>";
String contentId = "<YourUGCContentId>";
String userId = "<user-id>";
try {
publicContentV2Wrapper.publicDeleteContentV2(PublicDeleteContentV2.builder()
.namespace("<namespace>")
.userId(userId)
.channelId(channelId)
.contentId(contentId)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
import accelbyte_py_sdk.api.ugc as ugc_service
result, error = ugc_service.public_delete_content_v2(
channel_id="YourChannelId",
content_id="YourContentId",
user_id="********************************",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)