コード例 #1
0
    IEnumerator Start()
    {
        Log4ConfigManager.InitLog4net();
        Application.logMessageReceived += UnityLogCapturer.ApplicationOnLogMessageReceived;
#if !UNITY_EDITOR
        BootArg = new string[0];
#endif
        if (null == BootArg)
        {
            BootArg = new string[0];
        }

        var bootCmd =
            CmdParser.ParseCommandLine(BootArg.Length != 0 ? BootArg : System.Environment.GetCommandLineArgs());

        QualitySettings.shadowDistance = 120;
        PlayerPrefs.DeleteKey("unity_server_mode");

        _isDestroy = false;
        var hallController = GetHallController();
        if (hallController == null)
        {
#if UNITY_EDITOR
            SharedConfig.IsOffline   = Offline;
            SharedConfig.IsRobot     = IsRobot;
            SharedConfig.MutilThread = !DisableMutilThread;
            SharedConfig.DisableDoor = DisableDoor;
#endif
            SharedConfig.InitConfigBootArgs(bootCmd);
        }
        else
        {
            SharedConfig.IsOffline = false;
        }

        SharedConfig.IsServer = false;
        // 删除是否服务器数据


        _logger = new LoggerAdapter(typeof(ClientGameController));

        RegisterClientCallback();

        InitPhysicsSimulation();

        InitCamera();
        ComponentAllocateManager.Instance.Init();

        if (hallController == null)
        {
            _assetLoader = new AssetPool(this);
            yield return(StartCoroutine(_assetLoader.Init(SingletonManager.Get <ClientFileSystemConfigManager>().BootConfig.Resource,
                                                          SharedConfig.IsServer)));

            DoStart();
        }
        else
        {
            _assetLoader = AssetPool.Instance;
            HallUtility.GetGameClientInfo();
            _logger.InfoFormat("GetGameClientInfo...");
        }

        MyHttpServer.Start(SingletonManager.Get <ClientFileSystemConfigManager>().BootConfig.HttpPort, _clientRoom);
#if UNITY_SOURCE_MODIFIED && !UNITY_EDITOR
        if (!SharedConfig.InSamplingMode && !SharedConfig.InLegacySampleingMode)
        {
            UnityProfiler.EnableProfiler(true);
        }
#endif
    }