[U] add PlayFab SDK and SNS login improvements

- Add PlayFabSDK as local package dependency
- Add PlayFabTool.cs for PlayFab API integration
- Implement LoginBySns method in TYSdkFacade
- Add Android SNS login support in SDKManager and UnityBridgeFunc
- Add Build Android With Debug menu option
- Improve exception handling and timeout management

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-29 16:12:17 +08:00
parent 638e6a3327
commit aa5ce1ff5a
226 changed files with 64975 additions and 62 deletions

View File

@@ -0,0 +1,14 @@
#if !DISABLE_PLAYFABENTITY_API
using PlayFab.EventsModels;
namespace PlayFab.Events
{
public partial class PlayFabEvents
{
public event PlayFabRequestEvent<WriteEventsRequest> OnEventsWriteEventsRequestEvent;
public event PlayFabResultEvent<WriteEventsResponse> OnEventsWriteEventsResultEvent;
public event PlayFabRequestEvent<WriteEventsRequest> OnEventsWriteTelemetryEventsRequestEvent;
public event PlayFabResultEvent<WriteEventsResponse> OnEventsWriteTelemetryEventsResultEvent;
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 816bf581b4b09c04bbf42adfea99a423
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,67 @@
#if !DISABLE_PLAYFABENTITY_API && !DISABLE_PLAYFAB_STATIC_API
using System;
using System.Collections.Generic;
using PlayFab.EventsModels;
using PlayFab.Internal;
namespace PlayFab
{
/// <summary>
/// Write custom PlayStream and Telemetry events for any PlayFab entity. Telemetry events can be used for analytic,
/// reporting, or debugging. PlayStream events can do all of that and also trigger custom actions in near real-time.
/// </summary>
public static class PlayFabEventsAPI
{
static PlayFabEventsAPI() {}
/// <summary>
/// Verify entity login.
/// </summary>
public static bool IsEntityLoggedIn()
{
return PlayFabSettings.staticPlayer.IsEntityLoggedIn();
}
/// <summary>
/// Clear the Client SessionToken which allows this Client to call API calls requiring login.
/// A new/fresh login will be required after calling this.
/// </summary>
public static void ForgetAllCredentials()
{
PlayFabSettings.staticPlayer.ForgetAllCredentials();
}
/// <summary>
/// Write batches of entity based events to PlayStream. The namespace of the Event must be 'custom' or start with 'custom.'.
/// </summary>
public static void WriteEvents(WriteEventsRequest request, Action<WriteEventsResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;
var callSettings = PlayFabSettings.staticSettings;
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
PlayFabHttp.MakeApiCall("/Event/WriteEvents", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
}
/// <summary>
/// Write batches of entity based events to as Telemetry events (bypass PlayStream). The namespace must be 'custom' or start
/// with 'custom.'
/// </summary>
public static void WriteTelemetryEvents(WriteEventsRequest request, Action<WriteEventsResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;
var callSettings = PlayFabSettings.staticSettings;
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
PlayFabHttp.MakeApiCall("/Event/WriteTelemetryEvents", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6209aee5722aa2c46ba625e1944d6fa8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,81 @@
#if !DISABLE_PLAYFABENTITY_API
using System;
using System.Collections.Generic;
using PlayFab.EventsModels;
using PlayFab.Internal;
using PlayFab.SharedModels;
namespace PlayFab
{
/// <summary>
/// Write custom PlayStream and Telemetry events for any PlayFab entity. Telemetry events can be used for analytic,
/// reporting, or debugging. PlayStream events can do all of that and also trigger custom actions in near real-time.
/// </summary>
public class PlayFabEventsInstanceAPI : IPlayFabInstanceApi
{
public readonly PlayFabApiSettings apiSettings = null;
public readonly PlayFabAuthenticationContext authenticationContext = null;
public PlayFabEventsInstanceAPI(PlayFabAuthenticationContext context)
{
if (context == null)
throw new PlayFabException(PlayFabExceptionCode.AuthContextRequired, "Context cannot be null, create a PlayFabAuthenticationContext for each player in advance, or call <PlayFabClientInstanceAPI>.GetAuthenticationContext()");
authenticationContext = context;
}
public PlayFabEventsInstanceAPI(PlayFabApiSettings settings, PlayFabAuthenticationContext context)
{
if (context == null)
throw new PlayFabException(PlayFabExceptionCode.AuthContextRequired, "Context cannot be null, create a PlayFabAuthenticationContext for each player in advance, or call <PlayFabClientInstanceAPI>.GetAuthenticationContext()");
apiSettings = settings;
authenticationContext = context;
}
/// <summary>
/// Verify entity login.
/// </summary>
public bool IsEntityLoggedIn()
{
return authenticationContext == null ? false : authenticationContext.IsEntityLoggedIn();
}
/// <summary>
/// Clear the Client SessionToken which allows this Client to call API calls requiring login.
/// A new/fresh login will be required after calling this.
/// </summary>
public void ForgetAllCredentials()
{
if (authenticationContext != null)
{
authenticationContext.ForgetAllCredentials();
}
}
/// <summary>
/// Write batches of entity based events to PlayStream. The namespace of the Event must be 'custom' or start with 'custom.'.
/// </summary>
public void WriteEvents(WriteEventsRequest request, Action<WriteEventsResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
PlayFabHttp.MakeApiCall("/Event/WriteEvents", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
}
/// <summary>
/// Write batches of entity based events to as Telemetry events (bypass PlayStream). The namespace must be 'custom' or start
/// with 'custom.'
/// </summary>
public void WriteTelemetryEvents(WriteEventsRequest request, Action<WriteEventsResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
PlayFabHttp.MakeApiCall("/Event/WriteTelemetryEvents", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: efc8181560ecd0748a12a6df7137998e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,89 @@
#if !DISABLE_PLAYFABENTITY_API
using System;
using System.Collections.Generic;
using PlayFab.SharedModels;
namespace PlayFab.EventsModels
{
/// <summary>
/// Combined entity type and ID structure which uniquely identifies a single entity.
/// </summary>
[Serializable]
public class EntityKey : PlayFabBaseModel
{
/// <summary>
/// Unique ID of the entity.
/// </summary>
public string Id;
/// <summary>
/// Entity type. See https://docs.microsoft.com/gaming/playfab/features/data/entities/available-built-in-entity-types
/// </summary>
public string Type;
}
[Serializable]
public class EventContents : PlayFabBaseModel
{
/// <summary>
/// The optional custom tags associated with the event (e.g. build number, external trace identifiers, etc.). Before an
/// event is written, this collection and the base request custom tags will be merged, but not overriden. This enables the
/// caller to specify static tags and per event tags.
/// </summary>
public Dictionary<string,string> CustomTags;
/// <summary>
/// Entity associated with the event. If null, the event will apply to the calling entity.
/// </summary>
public EntityKey Entity;
/// <summary>
/// The namespace in which the event is defined. Allowed namespaces can vary by API.
/// </summary>
public string EventNamespace;
/// <summary>
/// The name of this event.
/// </summary>
public string Name;
/// <summary>
/// The original unique identifier associated with this event before it was posted to PlayFab. The value might differ from
/// the EventId value, which is assigned when the event is received by the server.
/// </summary>
public string OriginalId;
/// <summary>
/// The time (in UTC) associated with this event when it occurred. If specified, this value is stored in the
/// OriginalTimestamp property of the PlayStream event.
/// </summary>
public DateTime? OriginalTimestamp;
/// <summary>
/// Arbitrary data associated with the event. Only one of Payload or PayloadJSON is allowed.
/// </summary>
public object Payload;
/// <summary>
/// Arbitrary data associated with the event, represented as a JSON serialized string. Only one of Payload or PayloadJSON is
/// allowed.
/// </summary>
public string PayloadJSON;
}
[Serializable]
public class WriteEventsRequest : PlayFabRequestCommon
{
/// <summary>
/// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.).
/// </summary>
public Dictionary<string,string> CustomTags;
/// <summary>
/// The collection of events to write. Up to 200 events can be written per request.
/// </summary>
public List<EventContents> Events;
}
[Serializable]
public class WriteEventsResponse : PlayFabResultCommon
{
/// <summary>
/// The unique identifiers assigned by the server to the events, in the same order as the events in the request. Only
/// returned if FlushToPlayStream option is true.
/// </summary>
public List<string> AssignedEventIds;
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9ee524faa41ee444ca207259e58e70a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: