Exemplo n.º 1
0
    public void StartGame()
    {
        // Apply the configuration settings.
        UnityWorker.ApplyConfiguration(Configuration);

        // UnityWorker.TemplateProvider = <custom template provider>;
        // UnityWorker.AssetsToPrePool = <list of assets to prepool>;
        // UnityWorker.AssetsToPrecache = <list of assets to precache>;

        switch (UnityWorker.Configuration.EnginePlatform)
        {
        case EnginePlatform.FSim:
            // The UnitySDK no longer automatically exits upon disconnection.
            UnityWorker.OnDisconnected += reason => Application.Quit();

            // The UnitySDK no longer manages the framerate automatically.
            var targetFramerate = 120;
            var fixedFramerate  = 20;

            // Please see https://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html for more information.
            Application.targetFrameRate = targetFramerate;

            // Please see https://docs.unity3d.com/ScriptReference/Time-fixedDeltaTime.html for more information.
            Time.fixedDeltaTime = 1.0f / fixedFramerate;
            break;

        case EnginePlatform.Client:
            // UnityWorker.OnDisconnected += reason => <Return to main menu, etc.>;
            break;
        }

        // Start connecting to SpatialOS.
        UnityWorker.Connect(gameObject);
    }
Exemplo n.º 2
0
    public void Start()
    {
        UnityWorker.ApplyConfiguration(Configuration);

        switch (UnityWorker.Configuration.EnginePlatform)
        {
        case EnginePlatform.FSim:
            UnityWorker.OnDisconnected += reason => Application.Quit();

            var targetFramerate = 120;
            var fixedFramerate  = 20;

            Application.targetFrameRate = targetFramerate;
            Time.fixedDeltaTime         = 1.0f / fixedFramerate;
            break;
        }

        UnityWorker.Connect(gameObject);
    }