void Start()
    {
        startupManager = GameObject.FindGameObjectWithTag ( "Manager" ).GetComponent<StartupManager> ();
        musicViewer = GameObject.FindGameObjectWithTag ( "MusicViewer" ).GetComponent<MusicViewer> ();

        leftAudioOutput = new float[numSamples];
        rightAudioOutput = new float[numSamples];
        leftSpectrum = new float[numSamples];
        rightSpectrum = new float[numSamples];
        leftFCur = new float [numSamples];
        rightFCur = new float [numSamples];
        leftFMax = new float [numSamples];
        rightFMax = new float [numSamples];

        topLeftLine.SetVertexCount ( numSamples );
        bottomLeftLine.SetVertexCount ( numSamples );
        topRightLine.SetVertexCount ( numSamples );
        bottomRightLine.SetVertexCount ( numSamples );
    }
    void Start()
    {
        startupManager = GameObject.FindGameObjectWithTag ( "Manager" ).GetComponent<StartupManager> ();
        musicViewer = GameObject.FindGameObjectWithTag ( "MusicViewer" ).GetComponent<MusicViewer> ();
        paneManager = GameObject.FindGameObjectWithTag ( "Manager" ).GetComponent<PaneManager> ();

        onlineMusicBrowserPosition.width = Screen.width;
        onlineMusicBrowserPosition.height = Screen.height;
        onlineMusicBrowserPosition.x = onlineMusicBrowserPosition.width + onlineMusicBrowserPosition.width / 4;

        labelStyle = new GUIStyle ();
        labelStyle.alignment = TextAnchor.MiddleCenter;
        labelStyle.wordWrap = true;

        infoLabelStyle = new GUIStyle ();
        infoLabelStyle.alignment = TextAnchor.MiddleLeft;
        infoLabelStyle.fontSize = 16;

        sortLabelStyle = new GUIStyle ();
        sortLabelStyle.alignment = TextAnchor.MiddleRight;
        sortLabelStyle.fontSize = 16;

        buttonStyle = new GUIStyle ();
        buttonStyle.fontSize = 16;
        buttonStyle.alignment = TextAnchor.MiddleCenter;
        buttonStyle.border = new RectOffset ( 6, 6, 6, 4 );
        buttonStyle.padding = new RectOffset ( 6, 6, 3, 3 );
        buttonStyle.hover.background = guiHover;
        buttonStyle.active.background = guiActiveHover;

        artworkStyle = new GUIStyle ();
        artworkStyle.border = new RectOffset ( 6, 6, 6, 6 );
        artworkStyle.padding = new RectOffset ( 6, 6, 6, 6 );
        artworkStyle.hover.background = guiHover;

        GUIStyle flagStyle = new GUIStyle ();
        flagStyle.normal.background = flagNormal;
        flagStyle.hover.background = flagHover;
        flagStyle.border = new RectOffset ( 0, 0, 0, 0 );

        GUIStyle flagStyleActive = new GUIStyle ();
        flagStyleActive.normal.background = flagOnNormal;
        flagStyleActive.hover.background = flagOnHover;
        flagStyleActive.border = new RectOffset ( 0, 0, 0, 0 );

        GUIStyle clockStyle = new GUIStyle ();
        clockStyle.normal.background = clockNormal;
        clockStyle.hover.background = clockHover;
        clockStyle.border = new RectOffset ( 0, 0, 0, 0 );

        GUIStyle clockStyleActive = new GUIStyle ();
        clockStyleActive.normal.background = clockOnNormal;
        clockStyleActive.hover.background = clockOnHover;
        clockStyleActive.border = new RectOffset ( 0, 0, 0, 0 );

        GUIStyle textStyle = new GUIStyle ();
        textStyle.normal.background = textNormal;
        textStyle.hover.background = textHover;
        textStyle.border = new RectOffset ( 0, 0, 0, 0 );

        GUIStyle textStyleActive = new GUIStyle ();
        textStyleActive.normal.background = textOnNormal;
        textStyleActive.hover.background = textOnHover;
        textStyleActive.border = new RectOffset ( 0, 0, 0, 0 );

        GUIStyle recordStyle = new GUIStyle ();
        recordStyle.normal.background = recordNormal;
        recordStyle.hover.background = recordHover;
        recordStyle.border = new RectOffset ( 0, 0, 0, 0 );

        GUIStyle recordStyleActive = new GUIStyle ();
        recordStyleActive.normal.background = recordOnNormal;
        recordStyleActive.hover.background = recordOnHover;
        recordStyleActive.border = new RectOffset ( 0, 0, 0, 0 );

        GUIStyle personStyle = new GUIStyle ();
        personStyle.normal.background = personNormal;
        personStyle.hover.background = personHover;
        personStyle.border = new RectOffset ( 0, 0, 0, 0 );

        GUIStyle personStyleActive = new GUIStyle ();
        personStyleActive.normal.background = personOnNormal;
        personStyleActive.hover.background = personOnHover;
        personStyleActive.border = new RectOffset ( 0, 0, 0, 0 );

        GUIStyle listStyle = new GUIStyle ();
        listStyle.normal.background = listNormal;
        listStyle.hover.background = listHover;
        listStyle.border = new RectOffset ( 0, 0, 0, 0 );

        GUIStyle listStyleActive = new GUIStyle ();
        listStyleActive.normal.background = listOnNormal;
        listStyleActive.hover.background = listOnHover;
        listStyleActive.border = new RectOffset ( 0, 0, 0, 0 );

        availableSorts = new List<Sort> ()
        {

            new Sort ( "Featured", 1, flagStyle, flagStyleActive ),
            new Sort ( "Recent", 2, clockStyle, clockStyleActive ),
            new Sort ( "Name", 3, textStyle, textStyleActive ),
            new Sort ( "Album", 4, recordStyle, recordStyleActive ),
            new Sort ( "Artist", 5, personStyle, personStyleActive ),
            new Sort ( "Genre", 6, listStyle, listStyleActive )
        };
    }
    void Start()
    {
        ServicePointManager.ServerCertificateValidationCallback += delegate ( object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors ) { return true; };

        if ( developmentMode == true )
            UnityEngine.Debug.Log ( "Development Mode is ON" );

        onlineMusicBrowser = GameObject.FindGameObjectWithTag ( "OnlineMusicBrowser" ).GetComponent<OnlineMusicBrowser>();
        musicViewer = GameObject.FindGameObjectWithTag ( "MusicViewer" ).GetComponent<MusicViewer>();
        paneManager = gameObject.GetComponent<PaneManager>();

        if ( Environment.OSVersion.ToString ().Substring ( 0, 4 ) == "Unix" )
        {

            path = mac;
            twoCatStudiosPath = Path.DirectorySeparatorChar + "Users" + Path.DirectorySeparatorChar  + Environment.UserName + Path.DirectorySeparatorChar + "Library" + Path.DirectorySeparatorChar  + "Application Support" + Path.DirectorySeparatorChar + "2Cat Studios" + Path.DirectorySeparatorChar;
            directoryBrowser = "Finder";
        } else
        {

            path = windows;
            twoCatStudiosPath = Environment.GetFolderPath ( Environment.SpecialFolder.CommonApplicationData ) + Path.DirectorySeparatorChar + "2Cat Studios" + Path.DirectorySeparatorChar;
            directoryBrowser = "File Explorer";
        }

        mediaPath = path + "Media" + Path.DirectorySeparatorChar;
        supportPath = path + "Support" + Path.DirectorySeparatorChar;
        downloadedPath = mediaPath + "Downloaded" + Path.DirectorySeparatorChar;
        helpPath = supportPath + Path.DirectorySeparatorChar + "FAQ & Tutorial.txt" + Path.DirectorySeparatorChar;
        slideshowPath = path + "Slideshow" + Path.DirectorySeparatorChar;
        tempPath = supportPath + "Temp" + Path.DirectorySeparatorChar;

        preferences.lastDirectory = mediaPath.Substring ( 0, mediaPath.Length - 1 );

        if ( !Directory.Exists ( twoCatStudiosPath ))
        {

            UnityEngine.Debug.Log ( twoCatStudiosPath + " does not exist!" );
            Directory.CreateDirectory ( twoCatStudiosPath );
        }

        if ( ReadTwoCatSettings () == true )
        {

            if ( WriteTwoCatSettings () == true )
            {

                if ( developmentMode == true )
                {

                    UnityEngine.Debug.Log ( "TwoCat Settings Loaded Successfully" );
                }
            }
        } else {

            if ( WriteTwoCatSettings () != true )
            {

                UnityEngine.Debug.LogError ( "Unable to Write TwoCat Settings!" );
            }
        }

        if ( !Directory.Exists ( mediaPath ))
            Directory.CreateDirectory ( mediaPath );

        if ( !Directory.Exists ( mediaPath + "Albums" ))
            Directory.CreateDirectory ( mediaPath + "Albums" );

        if ( !Directory.Exists ( mediaPath + "Artists" ))
            Directory.CreateDirectory ( mediaPath + "Artists" );

        if ( !Directory.Exists ( mediaPath + "Genres" ))
            Directory.CreateDirectory ( mediaPath + "Genres" );

        if ( !Directory.Exists ( mediaPath + "Playlists" ))
            Directory.CreateDirectory ( mediaPath + "Playlists" );

        if ( !Directory.Exists ( mediaPath + "Downloaded" ))
            Directory.CreateDirectory ( mediaPath + "Downloaded" );

        if ( !Directory.Exists ( supportPath ))
            Directory.CreateDirectory(supportPath );

        if ( !Directory.Exists ( slideshowPath ))
        {

            Directory.CreateDirectory ( slideshowPath );
            File.Copy ( Application.streamingAssetsPath + Path.DirectorySeparatorChar + "UnityMusicPlayerIcon.png", slideshowPath + "UnityMusicPlayerIcon.png", true );
        }

        if ( !File.Exists ( slideshowPath + "UnityMusicPlayerIcon.png" ))
            File.Copy ( Application.streamingAssetsPath + Path.DirectorySeparatorChar + "UnityMusicPlayerIcon.png", slideshowPath + "UnityMusicPlayerIcon.png", true );

        if ( !Directory.Exists ( tempPath ))
        {

            Directory.CreateDirectory ( tempPath );
        } else if ( Directory.GetFiles ( tempPath ).Length > 0 )
        {

            DirectoryInfo tempDirectory = new DirectoryInfo ( tempPath );
            tempDirectory.Delete ( true );

            Directory.CreateDirectory ( tempPath );
        }

        if ( ReadPreferences () == true )
        {

            if ( WritePreferences () == true )
            {

                if ( developmentMode == true )
                {

                    UnityEngine.Debug.Log ( "Universal Settings Loaded Successfully" );
                }
            }
        } else {

            if ( WritePreferences () != true )
            {

                UnityEngine.Debug.LogError ( "Unable to Write Universal Settings!" );
            }
        }

        if ( !Directory.Exists ( preferences.lastDirectory ))
        {

            preferences.lastDirectory = mediaPath.Substring ( 0, mediaPath.Length - 1 );
        }

        if ( !File.Exists ( supportPath + "FAQ & Tutorial.txt" ) || !File.Exists ( supportPath + "ReadMe.txt" ))
        {

            File.Copy ( Application.streamingAssetsPath + Path.DirectorySeparatorChar + "FAQ & Tutorial.txt", supportPath + "FAQ & Tutorial.txt", true );
            File.Copy ( Application.streamingAssetsPath + Path.DirectorySeparatorChar + "ReadMe.txt", supportPath + "ReadMe.txt",true  );

        } else if ( developmentMode == false )
        {

            try
            {

                TextReader faq = File.OpenText ( supportPath + "FAQ & Tutorial.txt" );
                TextReader readme = File.OpenText ( supportPath + "ReadMe.txt" );

                string faqVersion = faq.ReadLine ().Substring ( 17 );
                string readmeVersion = readme.ReadLine ().Substring ( 17 );

                faq.Close ();
                readme.Close ();

                try
                {

                    if (float.Parse(faqVersion, CultureInfo.InvariantCulture.NumberFormat) < float.Parse(runningVersion))
                    {

                        File.Delete(supportPath + "FAQ & Tutorial.txt");
                        File.Copy(Application.streamingAssetsPath + Path.DirectorySeparatorChar + "FAQ & Tutorial.txt", supportPath + "FAQ & Tutorial.txt");
                    }
                    if (float.Parse(readmeVersion, CultureInfo.InvariantCulture.NumberFormat) < float.Parse(runningVersion))
                    {

                        File.Delete(supportPath + "ReadMe.txt");
                        File.Copy(Application.streamingAssetsPath + Path.DirectorySeparatorChar + "ReadMe.txt", supportPath + "ReadMe.txt");
                    }
                }
                catch (Exception e)
                {

                    UnityEngine.Debug.Log ( "Unable to Read FAQ and Tutorial/ReadMe, rewritting, " + e );

                    File.Delete(supportPath + "FAQ & Tutorial.txt");
                    File.Copy(Application.streamingAssetsPath + Path.DirectorySeparatorChar + "FAQ & Tutorial.txt", supportPath + "FAQ & Tutorial.txt");

                    File.Delete(supportPath + "ReadMe.txt");
                    File.Copy(Application.streamingAssetsPath + Path.DirectorySeparatorChar + "ReadMe.txt", supportPath + "ReadMe.txt");
                }
            }
            catch ( ArgumentOutOfRangeException error )
            {

                UnityEngine.Debug.Log ( "FAQ or ReadMe is not formatted properly! " + error );

                File.Delete ( supportPath + "FAQ & Tutorial.txt" );
                File.Copy ( Application.streamingAssetsPath + Path.DirectorySeparatorChar + "FAQ & Tutorial.txt", supportPath + "FAQ & Tutorial.txt" );

                File.Delete ( supportPath + "ReadMe.txt" );
                File.Copy ( Application.streamingAssetsPath + Path.DirectorySeparatorChar + "ReadMe.txt", supportPath + "ReadMe.txt" );
            }
        }

        prefsLocation = supportPath + "Preferences.umpp";

        if ( preferences.checkForUpdate == true || preferences.enableOMB == true )
        {

            Thread internetConnectionsThread = new Thread (() => InternetConnections ( preferences.checkForUpdate, preferences.enableOMB ));
            internetConnectionsThread.Start ();

            if ( preferences.enableOMB == true )
            {

                paneManager.loading = true;
                connectionInformation.text = "Connecting to the OnlineMusicDatabase";
                startTime = Time.realtimeSinceStartup;
                InvokeRepeating ( "CheckStartOnlineMusicBrowser", 0, 0.2F );
            }
        }
    }