Exemple #1
0
    private void Start()
    {
        if (GameObject.Find("Canvas") == null)
        {
            Debug.LogError("Make sure there is a canvas GameObject present in the Hierarcy.");
        }

        //Make sure game is unpaused
        GameController.Instance.gamePaused = false;

        //Get components for audio importer and source
#if UNITY_ANDROID
        audioImporter = gameObject.AddComponent <MobileImporter>();
#endif

#if UNITY_STANDALONE_WIN
        audioImporter = gameObject.AddComponent <NAudioImporter>();
#endif

        audioSource = GetComponent <AudioSource>();

        //Default URLs
        if (defaultURLs.Length > 0)
        {
            //Check PlayerPrefs to see if list already has been created
            if (PlayerPrefs.HasKey(playerPrefKey))
            {
                string[]      existingURLs = PlayerPrefExtension.Instance.GetStringArray(playerPrefKey);
                List <string> newURLs      = existingURLs.ToList();

                //Add all new unique URLs to the list
                foreach (string url in defaultURLs)
                {
                    if (!existingURLs.Contains(url))
                    {
                        newURLs.Add(url);
                    }
                }

                //Update PlayerPrefs
                PlayerPrefExtension.Instance.SetStringArray(playerPrefKey, newURLs.ToArray());
            }
            else
            {
                //PlayerPrefs does not contain any file URLs, so we create a new PlayerPref list
                PlayerPrefExtension.Instance.SetStringArray(playerPrefKey, defaultURLs);
            }
        }

        //Get list of file URLs
        fileURLs = PlayerPrefExtension.Instance.GetStringArray(playerPrefKey);
    }
Exemple #2
0
    private void Start()
    {
        audioSource = GetComponent <AudioSource>();

#if UNITY_ANDROID
        audioImporter = gameObject.AddComponent <MobileImporter>();
#endif

#if UNITY_STANDALONE_WIN
        audioImporter = gameObject.AddComponent <NAudioImporter>();
#endif

        audioSource.clip = null;
        playImmediate    = false;
    }