Пример #1
0
    // 资源已经加载完毕
    public void notifyAssetLoaded(UnityEngine.Object[] assets)
    {
        // 检查资源是否正常加载完成,如果在资源异步加载过程中资源包被卸载了,则资源无法正常加载完成
        bool hasAssets = true;

        if (assets != null)
        {
            foreach (var item in assets)
            {
                if (item == null)
                {
                    hasAssets = false;
                    break;
                }
            }
        }
        if (hasAssets)
        {
            mSubAssets = assets;
            mLoadState = LOAD_STATE.LS_LOADED;
        }
        else
        {
            mSubAssets = null;
            mLoadState = LOAD_STATE.LS_NONE;
        }
        callbackAll(mSubAssets);
    }
Пример #2
0
    // 资源包异步加载完成
    public void notifyAssetBundleAsyncLoadedDone(AssetBundle assetBundle)
    {
        mAssetBundle = assetBundle;
        if (mLoadState != LOAD_STATE.LS_UNLOAD)
        {
            mLoadState = LOAD_STATE.LS_LOADED;
            // 异步加载请求的资源
            foreach (var assetInfo in mLoadAsyncList)
            {
                loadAssetAsync(assetInfo.getAssetName(), null, null, null);
            }
        }
        // 加载状态为已卸载,表示在异步加载过程中,资源包被卸载掉了
        else
        {
            logWarning("资源包异步加载完成,但是异步加载过程中被卸载");
            unload();
        }
        int count = mLoadCallback.Count;

        for (int i = 0; i < count; ++i)
        {
            mLoadCallback[i](this, mLoadUserData[i]);
        }
        mLoadCallback.Clear();
        mLoadUserData.Clear();
    }
Пример #3
0
    // 同步加载资源包
    public void loadAssetBundle()
    {
        if (mLoaded != LOAD_STATE.LS_UNLOAD)
        {
            return;
        }
        // 先确保所有依赖项已经加载
        foreach (var info in mParents)
        {
            info.Value.loadAssetBundle();
        }
        // 然后加载AssetBundle
        mAssetBundle = AssetBundle.LoadFromFile(CommonDefine.F_STREAMING_ASSETS_PATH + mBundleName + CommonDefine.ASSET_BUNDLE_SUFFIX);
        if (mAssetBundle == null)
        {
            UnityUtility.logError("can not load asset bundle : " + mBundleName);
            return;
        }
        // 加载其中的所有资源
        List <string> assetNameList = new List <string>(mAssetList.Keys);
        int           assetCount    = assetNameList.Count;

        for (int i = 0; i < assetCount; ++i)
        {
            UnityEngine.Object obj = mAssetBundle.LoadAsset(CommonDefine.P_RESOURCE_PATH + assetNameList[i]);
            mAssetList[assetNameList[i]].mAssetObject = obj;
        }
        mLoaded = LOAD_STATE.LS_LOADED;
        // 通知自己的所有子节点,自己已经加载完了
        foreach (var item in mChildren)
        {
            item.Value.notifyParentLoaded(this);
        }
    }
Пример #4
0
 // 异步加载资源包
 public void loadAssetBundleAsync(AssetBundleLoadCallback callback, object userData)
 {
     // 正在加载,则加入等待列表
     if (mLoadState == LOAD_STATE.LS_LOADING || mLoadState == LOAD_STATE.LS_WAIT_FOR_LOAD)
     {
         if (callback != null)
         {
             mLoadCallback.Add(callback);
         }
     }
     // 如果还未加载,则加载资源包,回调加入列表
     else if (mLoadState == LOAD_STATE.LS_UNLOAD)
     {
         if (callback != null)
         {
             mLoadCallback.Add(callback);
             mLoadUserData.Add(userData);
         }
         // 先确保所有依赖项已经加载
         loadParentAsync();
         mLoadState = LOAD_STATE.LS_WAIT_FOR_LOAD;
         // 通知AssetBundleLoader请求异步加载AssetBundle,只在真正开始异步加载时才标记为正在加载状态,此处只是加入等待列表
         mResourceManager.mAssetBundleLoader.requestLoadAssetBundle(this);
     }
     // 加载完毕,直接调用回调
     else if (mLoadState == LOAD_STATE.LS_LOADED)
     {
         callback?.Invoke(this, userData);
     }
 }
Пример #5
0
    // 同步加载资源包
    public void loadAssetBundle()
    {
        if (mLoaded != LOAD_STATE.LS_UNLOAD)
        {
            return;
        }
        // 先确保所有依赖项已经加载
        foreach (var info in mParents)
        {
            info.Value.loadAssetBundle();
        }
        // 然后加载AssetBundle
#if UNITY_ANDROID && UNITY_EDITOR
        byte[] assetBundleBuffer = AndroidAssetLoader.loadAsset(mBundleName + CommonDefine.ASSET_BUNDLE_SUFFIX);
        mAssetBundle = AssetBundle.LoadFromMemory(assetBundleBuffer);
#else
        mAssetBundle = AssetBundle.LoadFromFile(CommonDefine.F_STREAMING_ASSETS_PATH + mBundleName + CommonDefine.ASSET_BUNDLE_SUFFIX);
#endif

        if (mAssetBundle == null)
        {
            logError("can not load asset bundle : " + mBundleName);
            return;
        }
        // 加载其中的所有资源
        List <string> assetNameList = new List <string>(mAssetList.Keys);
        int           assetCount    = assetNameList.Count;
        for (int i = 0; i < assetCount; ++i)
        {
            UnityEngine.Object obj = mAssetBundle.LoadAsset(CommonDefine.P_RESOURCE_PATH + assetNameList[i]);
            mAssetList[assetNameList[i]].mAssetObject = obj;
        }
        mLoaded = LOAD_STATE.LS_LOADED;
        afterLoaded();
    }
Пример #6
0
 public ResourceLoadInfo()
 {
     mCallback = new List <AssetLoadDoneCallback>();
     mUserData = new List <object>();
     mLoadPath = new List <string>();
     mState    = LOAD_STATE.UNLOAD;
 }
Пример #7
0
    // 资源已经加载完毕
    public void notifyAssetLoaded(UnityEngine.Object[] assets)
    {
        // 检查资源是否正常加载完成,如果在资源异步加载过程中资源包被卸载了,则资源无法正常加载完成
        bool hasAssets = true;

        if (assets != null)
        {
            int count = assets.Length;
            for (int i = 0; i < count; ++i)
            {
                if (assets[i] == null)
                {
                    hasAssets = false;
                    break;
                }
            }
        }
        if (hasAssets)
        {
            mSubAssets = assets;
            mLoadState = LOAD_STATE.LOADED;
        }
        else
        {
            mSubAssets = null;
            mLoadState = LOAD_STATE.NONE;
        }
        callbackAll(mSubAssets);
    }
Пример #8
0
 protected string mAssetName;                        // 资源文件名,带相对于StreamingAssets的相对路径,带后缀
 public AssetInfo(AssetBundleInfo parent, string name)
 {
     mParentAssetBundle = parent;
     mAssetName         = name;
     mSubAssets         = null;
     mCallback          = new List <AssetLoadDoneCallback>();
     mUserData          = new List <object[]>();
     mLoadPath          = new List <string>();
     mLoadState         = LOAD_STATE.LS_NONE;
 }
Пример #9
0
 public AssetBundleInfo(string bundleName)
 {
     mBundleName        = bundleName;
     mLoadedParentCount = 0;
     mLoaded            = LOAD_STATE.LS_UNLOAD;
     mParents           = new Dictionary <string, AssetBundleInfo>();
     mChildren          = new Dictionary <string, AssetBundleInfo>();
     mLoadAsyncList     = new Dictionary <string, AsyncLoadInfo>();
     mAssetList         = new Dictionary <string, AssetInfo>();
 }
Пример #10
0
 public void resetProperty()
 {
     mPath        = null;
     mResouceName = null;
     mObject      = null;
     mSubObjects  = null;
     mState       = LOAD_STATE.LS_UNLOAD;
     mCallback.Clear();
     mUserData.Clear();
     mLoadPath.Clear();
 }
Пример #11
0
 protected void doLoadAssets()
 {
     if (mSubAssets == null)
     {
         if (mParentAssetBundle.getAssetBundle() != null)
         {
             mSubAssets = mParentAssetBundle.getAssetBundle().LoadAssetWithSubAssets(CommonDefine.P_GAME_RESOURCES_PATH + mAssetName);
         }
         mLoadState = LOAD_STATE.LS_LOADED;
     }
 }
Пример #12
0
    // 同步加载资源包
    public void loadAssetBundle(bool persistentFirst)
    {
        if (mLoaded != LOAD_STATE.LS_UNLOAD)
        {
            return;
        }
        // 先确保所有依赖项已经加载
        foreach (var info in mParents)
        {
            info.Value.loadAssetBundle(persistentFirst);
        }
        // 然后加载AssetBundle
#if UNITY_ANDROID && !UNITY_EDITOR
        byte[] assetBundleBuffer = null;
        // 先去persistentDataPath中查找资源
        if (persistentFirst)
        {
            assetBundleBuffer = AndroidAssetLoader.loadFile(CommonDefine.F_PERSISTENT_DATA_PATH + mBundleName + CommonDefine.ASSET_BUNDLE_SUFFIX);
        }
        // 找不到再去StreamingAssets下查找
        if (assetBundleBuffer == null)
        {
            assetBundleBuffer = AndroidAssetLoader.loadAsset(mBundleName + CommonDefine.ASSET_BUNDLE_SUFFIX);
        }
        mAssetBundle = AssetBundle.LoadFromMemory(assetBundleBuffer);
#else
        // 先去persistentDataPath中查找资源
        if (persistentFirst && isFileExist(CommonDefine.F_PERSISTENT_DATA_PATH + mBundleName + CommonDefine.ASSET_BUNDLE_SUFFIX))
        {
            mAssetBundle = AssetBundle.LoadFromFile(CommonDefine.F_PERSISTENT_DATA_PATH + mBundleName + CommonDefine.ASSET_BUNDLE_SUFFIX);
        }
        // 找不到再去StreamingAssets下查找
        if (mAssetBundle == null && isFileExist(CommonDefine.F_STREAMING_ASSETS_PATH + mBundleName + CommonDefine.ASSET_BUNDLE_SUFFIX))
        {
            mAssetBundle = AssetBundle.LoadFromFile(CommonDefine.F_STREAMING_ASSETS_PATH + mBundleName + CommonDefine.ASSET_BUNDLE_SUFFIX);
        }
#endif
        if (mAssetBundle == null)
        {
            logError("can not load asset bundle : " + mBundleName);
            return;
        }
        // 加载其中的所有资源
        List <string> assetNameList = new List <string>(mAssetList.Keys);
        int           assetCount    = assetNameList.Count;
        for (int i = 0; i < assetCount; ++i)
        {
            UnityEngine.Object obj = mAssetBundle.LoadAsset(CommonDefine.P_RESOURCE_PATH + assetNameList[i]);
            mAssetList[assetNameList[i]].mAssetObject = obj;
        }
        mLoaded = LOAD_STATE.LS_LOADED;
        afterLoaded();
    }
Пример #13
0
 protected string mBundleFileName;                           // 资源所在的AssetBundle名,相对于StreamingAsset,含后缀
 public AssetBundleInfo(string bundleName)
 {
     mBundleName     = bundleName;
     mBundleFileName = mBundleName + CommonDefine.ASSET_BUNDLE_SUFFIX;
     mLoadState      = LOAD_STATE.LS_UNLOAD;
     mParents        = new Dictionary <string, AssetBundleInfo>();
     mChildren       = new Dictionary <string, AssetBundleInfo>();
     mLoadAsyncList  = new List <AssetInfo>();
     mAssetList      = new Dictionary <string, AssetInfo>();
     mObjectToAsset  = new Dictionary <Object, AssetInfo>();
     mLoadCallback   = new List <AssetBundleLoadCallback>();
     mLoadUserData   = new List <object>();
 }
Пример #14
0
 // 异步加载资源
 public void loadAssetAsync()
 {
     // 如果资源已经存在,则直接返回
     if (mSubAssets != null)
     {
         callbackAll(mSubAssets);
     }
     else
     {
         mLoadState = LOAD_STATE.LS_WAIT_FOR_LOAD;
         mResourceManager.mAssetBundleLoader.requestLoadAsset(mParentAssetBundle, mAssetName);
     }
 }
Пример #15
0
    public void notifyAssetBundleAsyncLoadedDone(AssetBundle assetBundle)
    {
        mLoaded      = LOAD_STATE.LS_LOADED;
        mAssetBundle = assetBundle;

        // 通知请求的资源回调
        foreach (var assetInfo in mLoadAsyncList)
        {
            if (assetInfo.Value.mCallback != null)
            {
                assetInfo.Value.mCallback(assetInfo.Value.mAssetInfo.mAssetObject, null, assetInfo.Value.mUserData);
            }
        }
        mLoadAsyncList.Clear();
        afterLoaded();
    }
Пример #16
0
 public void unload()
 {
     if (mAssetBundle != null)
     {
         logInfo("unload : " + mBundleName);
         // 为true表示会卸载掉LoadAsset加载的资源,并不影响该资源实例化的物体
         mAssetBundle.Unload(true);
         mAssetBundle = null;
     }
     mObjectToAsset.Clear();
     foreach (var item in mAssetList)
     {
         item.Value.unload();
     }
     mLoadState = LOAD_STATE.LS_UNLOAD;
 }
Пример #17
0
 // 异步加载资源包
 public void loadAssetBundleAsync(AssetBundleLoadDoneCallback callback)
 {
     if (mLoaded != LOAD_STATE.LS_UNLOAD)
     {
         return;
     }
     // 先确保所有依赖项已经加载
     foreach (var info in mParents)
     {
         info.Value.loadAssetBundleAsync(null);
     }
     // 通知AssetBundleLoader请求异步加载AssetBundle
     mLoaded = LOAD_STATE.LS_LOADING;
     mResourceManager.mAssetBundleLoader.requestLoadAssetBundle(this);
     mAssetBundleLoadCallback = callback;
 }
Пример #18
0
    public void unload()
    {
        if (mAssetBundle != null)
        {
#if UNITY_EDITOR || DEVELOPMENT_BUILD
            log("unload : " + mBundleName);
#endif
            // 为true表示会卸载掉LoadAsset加载的资源,并不影响该资源实例化的物体
            mAssetBundle.Unload(true);
            mAssetBundle = null;
        }
        mObjectToAsset.Clear();
        foreach (var item in mAssetList)
        {
            item.Value.unload();
        }
        mLoadState = LOAD_STATE.UNLOAD;
    }
Пример #19
0
    // 同步加载资源包
    public void loadAssetBundle()
    {
        if (mLoadState != LOAD_STATE.UNLOAD && mLoadState != LOAD_STATE.NONE)
        {
            return;
        }
        // 先确保所有依赖项已经加载
        foreach (var info in mParents)
        {
            info.Value.loadAssetBundle();
        }
#if UNITY_EDITOR || DEVELOPMENT_BUILD
        log("加载AssetBundle:" + mBundleFileName, LOG_LEVEL.NORMAL);
#endif
        // 先去persistentDataPath中查找资源
        string path = FrameDefine.F_PERSISTENT_DATA_PATH + mBundleFileName;
        if (ResourceManager.mPersistentFirst && isFileExist(path))
        {
            mAssetBundle = AssetBundle.LoadFromFile(path);
        }
        // 找不到再去指定目录中查找资源
        if (mAssetBundle == null)
        {
            path = ResourceManager.mResourceRootPath + mBundleFileName;
            // 安卓平台下,如果是从StreamingAssets读取AssetBundle文件,则需要使用指定的路径
#if UNITY_ANDROID && !UNITY_EDITOR
            if (ResourceManager.mResourceRootPath == FrameDefine.F_STREAMING_ASSETS_PATH)
            {
                path = FrameDefine.F_ASSET_BUNDLE_PATH + mBundleFileName;
            }
#endif
            // 远端目录不判断文件是否存在,本地路径如果是StreamingAssets中
            // 则需要使用FrameDefine.F_STREAMING_ASSETS_PATH而不是FrameDefine.F_ASSET_BUNDLE_PATH
            if (!ResourceManager.mLocalRootPath || isFileExist(ResourceManager.mResourceRootPath + mBundleFileName))
            {
                mAssetBundle = AssetBundle.LoadFromFile(path);
            }
        }
        if (mAssetBundle == null)
        {
            logError("can not load asset bundle : " + mBundleFileName);
        }
        mLoadState = LOAD_STATE.LOADED;
    }
Пример #20
0
        public static void ReceivePlayerLoadedConfirm()
        {
            if (!isServerLoaded)
            {
                log.WriteLine("waiting for server..");
                return;
            }
            log.WriteLine("entering game");
            loadState = LOAD_STATE.INGAME;

            foreach (PlayerInfo inf in playerInfo.Values)
            {
                if (!playerEnts.ContainsKey(inf.id) && inf.state == PLAYER_STATE.Loaded)
                {
                    GeneratePlayerEnt(inf, inf.id == clientId);
                }
            }
            statemanager.SetState(new game_state(true));
        }
Пример #21
0
    public void notifyAssetBundleAsyncLoadedDone(AssetBundle assetBundle)
    {
        mLoaded      = LOAD_STATE.LS_LOADED;
        mAssetBundle = assetBundle;

        // 通知请求的资源回调
        foreach (var assetInfo in mLoadAsyncList)
        {
            if (assetInfo.Value.mCallback != null)
            {
                assetInfo.Value.mCallback(assetInfo.Value.mAssetInfo.mAssetObject);
            }
        }
        mLoadAsyncList.Clear();
        // 通知自己的所有子节点,自己已经加载完了
        foreach (var item in mChildren)
        {
            item.Value.notifyParentLoaded(this);
        }
    }
Пример #22
0
        public static void RecieveChangeLevel(string name)
        {
            playerEnts.Clear();
            level.ChangeLevel(name, true, callback: delegate {
                PlayerInfo i         = playerInfo[clientId];
                i.state              = PLAYER_STATE.Loaded;
                playerInfo[clientId] = i;

                loadState = LOAD_STATE.FINISHED;
                SendPlayerLoaded();
            });

            isServerLoaded = false;
            loadState      = LOAD_STATE.STARTED;
            foreach (int client in playerInfo.Keys.ToList())
            {
                PlayerInfo inf = playerInfo[client];
                inf.state          = PLAYER_STATE.Loading;
                playerInfo[client] = inf;
            }
        }
Пример #23
0
 public void unload()
 {
     mSubAssets = null;
     mLoadState = LOAD_STATE.LS_UNLOAD;
 }
Пример #24
0
        public static void Connect(string address = "localhost", int port = 9050)
        {
            EventBasedNetListener listener = new EventBasedNetListener();

            client = new NetManager(listener);
            client.Start();

            loadState = LOAD_STATE.NONE;
            log.WriteLine("connecting to " + address + ":" + port);
            try
            {
                client.Connect(address, port, "SomeConnectionKey");
            }
            catch (SocketException e)
            {
                log.WriteLine("connection failed (" + e.SocketErrorCode + ")");
                n_state.SetState(NETWORK_STATE.none);
            }

            listener.PeerConnectedEvent += (peer) =>
            {
                log.WriteLine("connected");
                SendPlayerConnect();
            };
            listener.PeerDisconnectedEvent += (peer, info) =>
            {
                log.WriteLine("disconnected (" + info.Reason + ")");
                n_state.SetState(NETWORK_STATE.none);
                statemanager.SetState(new console(), true);
            };

            listener.NetworkReceiveEvent += (peer, reader, deliveryMethod) =>
            {
                int type = reader.GetInt();
                switch (type)
                {
                case (int)NetworkedEvent.ClientWelcome:
                    RecieveClientWelcome(reader);
                    break;

                case (int)NetworkedEvent.PlayerSync:
                    if (loadState == LOAD_STATE.INGAME)
                    {
                        RecievePlayerSync(reader);
                    }
                    break;

                case (int)NetworkedEvent.ChangeLevel:
                    log.DebugLine("changing level");
                    RecieveChangeLevel(reader.GetString(100));
                    break;

                case (int)NetworkedEvent.PlayerLoadedConfirm:
                    ReceivePlayerLoadedConfirm();
                    break;

                case (int)NetworkedEvent.PlayerLoaded:
                    int id = reader.PeekInt();
                    log.DebugLine("reported player loaded: " + id);
                    if (id == -1)
                    {
                        isServerLoaded = true;
                        if (loadState == LOAD_STATE.INGAME)
                        {
                            ReceivePlayerLoadedConfirm();
                        }
                    }
                    break;

                case (int)NetworkedEvent.RefreshPlayerInfo:
                    RecieveRefreshPlayerInfo(reader);
                    break;

                default:
                    break;
                }
                game.game.HandleCommonEvents(type, peer, reader, deliveryMethod);
                reader.Recycle();
            };
        }
    // Update is called once per frame
    private void Update()
    {
        if (load_state == LOAD_STATE.NOT_LOADED)
        {
            if (beatMap.state == BeatMap.STATE.SAMPLES_LOADED)
            {
                generateBeats();
                audioSrc.Play();
                load_state = LOAD_STATE.LOADED;
            }
        }
        else
        {
            // score handler
            _pCombo.text = _playerCombo + "x";
            _pScore.text = _playerScore + "";

            // health/healthbar handler
            //Debug.Log(_playerHealth);
            //healthBarHandler();

            // decreases playerhealth at a fixed rate
            if (_playerHealth <= 0)
            {
                _gameState = GameState.game_over;
                //return;
            }
            else if (_playerHealth <= 30)
            {
                warningText.GetComponent <Text>().text = "Health Critical";
            }
            else
            {
                warningText.GetComponent <Text>().text = "";
            }

            if (_gameState == GameState.game_over) // game over state
            {
                Debug.Log("GAME OVER");
                pauseCanvas.SetActive(true);
                gameOverPanel.SetActive(true);

                Time.timeScale = 0;               // pauses game
                audioSrc.Stop();                  // stops audio playback
            }
            else if (_gameState == GameState.win) // victory state
            {
                SceneManager.LoadScene("VictoryRoyaleScene");
            }
            else   // otherwise keep decreasing the player's health
                   // _gamestate == gamestate.playing
            {
                if (Time.time - lastTime >= 0.1) // decreases at a specified rate
                {
                    _playerHealth -= _playerHealthDecreaseRate;
                    lastTime       = Time.time;
                }
            }
            GameObject.Find("HealthBar").GetComponent <Slider>().value = _playerHealth / TOTAL_PLAYER_HEALTH;
        }

        // handles the sliders in the settings panel
        // volume slider code
        audioSrc.volume = volumeSlider.value;
        // tilt sensitivity code
        MovementScript.tiltSensHorizontal = tiltSensSlider.value * 2.5f;
        MovementScript.tiltSensVertical   = tiltSensSlider.value * 2.5f;
        // sfx volume code
        //objective.GetComponent<AudioSource>().volume = sfxVolumeSlider.value;
        //badObjective.GetComponent<AudioSource>().volume = sfxVolumeSlider.value;
        sounds[1].volume = sfxVolumeSlider.value; // good sound
        sounds[2].volume = sfxVolumeSlider.value; // bad sound
        //print(sounds[2].volume);
    }
Пример #26
0
 public void setLoadState(LOAD_STATE state)
 {
     mLoadState = state;
 }
    void Start()
    {
        //Screen.SetResolution(1280, 720, true, 60);
        //mainCamera = GameObject.Find("Main Camera").GetComponent<Camera>();
        // first index is initial camera position/rotation
        //cameraPositions = new Vector3[] {mainCamera.transform.position, new Vector3(-313, -527, 1880)};
        //cameraRotations = new Quaternion[] {mainCamera.transform.rotation, Quaternion.Euler(-1.813f, -181.159f, 0)};
        warningText               = GameObject.Find("warningText");
        load_state                = LOAD_STATE.NOT_LOADED;
        _gameState                = GameState.playing;
        _playerScore              = 0;
        _playerCombo              = 1;
        _playerNotesHit           = 0;
        _playerMaxCombo           = 1;
        _pCombo                   = GameObject.Find("comboText").GetComponent <Text>();
        _pScore                   = GameObject.Find("scoreText").GetComponent <Text>();
        _playerHealth             = 100f;
        _playerHealthDecreaseRate = 1f;
        lastTime                  = Time.time;
        totalNotes                = 0;

        mainCamera = GameObject.Find("Main Camera");

        //gameOverPanel = GameObject.Find("GameOverPanel");
        gameOverPanel.SetActive(false);
        //gameOverRetryButton = GameObject.Find("GameOverRetryButton");
        //gameOverQuitButton = GameObject.Find("GameOverQuitButton");

        gameOverRetryButton.GetComponent <Button>().onClick.AddListener(handleGameOverRetry);
        gameOverQuitButton.GetComponent <Button>().onClick.AddListener(handleGameOverQuit);

        audioSrc = this.GetComponent <AudioSource>(); // there is an audiosource in beatmapplayer, but it is more convenient to create one here

        // do not render the pause canvas on launch
        //GameObject.Find("PauseCanvas").SetActive(false);

        LoadPlayerFromExternal(ref playerClass);

        // handle car visibility
        GameObject car_gt86  = GameObject.Find("car_gt86");
        GameObject car_merc  = GameObject.Find("car_merc");
        GameObject car_lambo = GameObject.Find("car_lambo");

        cars = new GameObject[] { car_gt86, car_merc, car_lambo }; // keep the order here the same as in MainMenuCanvasController

        btnSettings.onClick.AddListener(handleSettings);
        exitSettingsButton.onClick.AddListener(handleExitSettings);

        settingsPanel.SetActive(false);

        handleCarVisibility();

        beatMap = BeatMap.loadBeatMap();
        beatMap.loadSamples(this);

        objective    = GameObject.Find("Objective");
        badObjective = GameObject.Find("BadObjective");

        sounds = GetComponents <AudioSource>();

        // initial camera angle
        //mainCamera.transform.position = Vector3.MoveTowards(cameraPositions[1], cameraPositions[0], 20f);
        //mainCamera.transform.rotation = Quaternion.RotateTowards(cameraRotations[1], cameraRotations[0], 20f);


        // temp, generate gameobjects based on beatmap
        //Stream openFileStream = File.OpenRead(Application.persistentDataPath + "/BeatMaps/testBeatmap.dat");
        //BinaryFormatter deserializer = new BinaryFormatter();
        //BeatMap beatMap = (BeatMap)deserializer.Deserialize(openFileStream);
    }