Ejemplo n.º 1
0
        private static void Init()
        {
#endif
#if (UNITY_WEBGL || ENABLE_IL2CPP) && !UNITY_EDITOR
            Utf8Json.Resolvers.CompositeResolver.RegisterAndSetAsDefault(
                new [] {
                Utf8Json.Formatters.PrimitiveObjectFormatter.Default
            },
                new[] {
                Utf8Json.Resolvers.GeneratedResolver.Instance,
                Utf8Json.Resolvers.BuiltinResolver.Instance,
                Utf8Json.Resolvers.EnumResolver.Default,
                // for unity
                Utf8Json.Unity.UnityResolver.Instance
            }
                );
#endif

            var configFile = Resources.Load("AccelByteServerSDKConfig");

            if (configFile == null)
            {
                throw new Exception(
                          "'AccelByteServerSDKConfig.json' isn't found in the Project/Assets/Resources directory");
            }

            string wholeJsonText = ((TextAsset)configFile).text;

            AccelByteServerPlugin.config = wholeJsonText.ToObject <ServerConfig>();
            AccelByteServerPlugin.config.CheckRequiredField();
            AccelByteServerPlugin.config.Expand();
            AccelByteServerPlugin.coroutineRunner = new CoroutineRunner();
            AccelByteServerPlugin.httpClient      = new AccelByteHttpClient();

            AccelByteServerPlugin.session = new ServerOauthLoginSession(
                AccelByteServerPlugin.config.IamServerUrl,
                AccelByteServerPlugin.config.ClientId,
                AccelByteServerPlugin.config.ClientSecret,
                AccelByteServerPlugin.httpClient,
                AccelByteServerPlugin.coroutineRunner);

            AccelByteServerPlugin.server = new DedicatedServer(
                AccelByteServerPlugin.session,
                AccelByteServerPlugin.coroutineRunner);
        }
        static AccelByteServerPlugin()
        {
#if UNITY_EDITOR // Handle an unexpected behaviour if Domain Reload (experimental) is disabled
            EditorApplication.playModeStateChanged += state =>
            {
                if (state == PlayModeStateChange.ExitingEditMode)
                {
                    hasBeenInitialized = false;

                    accessToken            = null;
                    server                 = null;
                    dedicatedServerManager = null;
                    ecommerce              = null;
                    statistic              = null;
                    qos           = null;
                    gameTelemetry = null;
                    achievement   = null;
                    lobby         = null;
                    cloudSave     = null;
                }
            };
        }
Ejemplo n.º 3
0
        static AccelByteServerPlugin()
        {
#if UNITY_EDITOR // Handle an unexpected behaviour if Domain Reload (experimental) is disabled
            EditorApplication.playModeStateChanged += state =>
            {
                if (state != PlayModeStateChange.ExitingEditMode)
                {
                    return;
                }

                AccelByteServerPlugin.hasBeenInitialized     = false;
                AccelByteServerPlugin.accessToken            = null;
                AccelByteServerPlugin.server                 = null;
                AccelByteServerPlugin.dedicatedServerManager = null;
                AccelByteServerPlugin.ecommerce              = null;
                AccelByteServerPlugin.statistic              = null;
                AccelByteServerPlugin.qos           = null;
                AccelByteServerPlugin.gameTelemetry = null;
                AccelByteServerPlugin.achievement   = null;
                AccelByteServerPlugin.lobby         = null;
                AccelByteServerPlugin.cloudSave     = null;
                AccelByteServerPlugin.seasonPass    = null;
            };
        }