예제 #1
0
    IEnumerator LoadingProcess(string filename)
    {
        LoadingBar loading = LoadingBar.Show(true);
        //loading.SetProgress(0);
        string url = "file://" + filename;

        using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(url, AudioType.MPEG))
        {
            yield return(www.SendWebRequest());

            //loading.SetProgress(0.3f);

            if (www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                AudioClip audioClip = DownloadHandlerAudioClip.GetContent(www);
                mAudioSrc.clip   = audioClip;
                mAudioSrc.volume = 0.5f;

                //loading.SetProgress(0.5f);
                yield return(null);

                // DetectBPM(audioClip);
                IEnumDetectBPM detector = new IEnumDetectBPM(audioClip);
                yield return(detector);

                int bpm = detector.BPM;
                //loading.SetProgress(0.7f);

                float start = 0.5f;
                float end   = audioClip.length;
                mPanelBpmDelay.transform.Find(OBJECT_NAME_BPM).GetComponent <InputField>().text   = bpm.ToString();
                mPanelBpmDelay.transform.Find(OBJECT_NAME_START).GetComponent <InputField>().text = start.ToString();
                mPanelBpmDelay.transform.Find(OBJECT_NAME_END).GetComponent <InputField>().text   = end.ToString();
                mCustomTP.Initialize(bpm, start, end);
                mCustomTP.CreateRandomTPs(false);

                mPanelBpmDelay.SetActive(true);
                mPanelTPs.SetActive(true);
                mPanelFunctions.SetActive(true);

                yield return(null);
                //loading.SetProgress(1.0f);
            }
        }
        loading.Hide();
    }
예제 #2
0
 public void ShowProgressNonModal(bool show)
 {
     if (show)
     {
         UIApplication.SharedApplication.InvokeOnMainThread(() => {
             LoadingBar.Show();
         });
     }
     else
     {
         UIApplication.SharedApplication.InvokeOnMainThread(() => {
             LoadingBar.Hide();
         });
     }
 }
예제 #3
0
 private void Timer_Tick(object sender, EventArgs e)
 {
     if (LoadingBar.Value < 100)
     {
         LoadingBar.Value++;
     }
     else
     {
         Thread.Sleep(500);
         Loading.Visible = false;
         content.Hide();
         Timer.Stop();
         LoadingBar.Hide();
         Loading.Hide();
         loadingText.Hide();
         mailAnimator.ShowSync(content);
     }
 }
예제 #4
0
    IEnumerator SendToServerAsync(byte[] data)
    {
        LoadingBar    loadingbar  = LoadingBar.Show();
        NetworkStream stream      = mClient.GetStream();
        int           currentSize = data.Length;
        int           off         = 0;

        do
        {
            int sendSize = Math.Min(currentSize, PACKET_SIZE);
            try { stream.Write(data, off, sendSize); }
            catch (Exception ex) { Debug.Log(ex.ToString()); break; }
            off         += sendSize;
            currentSize -= sendSize;
            loadingbar.SetProgress(off / (float)data.Length);
            yield return(new WaitForEndOfFrame());
        } while (currentSize > 0);
        loadingbar.Hide();
    }
예제 #5
0
    IEnumerator ShowProgressBar()
    {
        LoadingBar loadingbar = LoadingBar.Show();

        while (!NetworkClient.Inst().IsRecvData())
        {
            yield return(new WaitForEndOfFrame());
        }

        float rate = 0;

        while (rate < 1f)
        {
            rate = NetworkClient.Inst().GetProgressState();
            loadingbar.SetProgress(rate);
            yield return(new WaitForEndOfFrame());
        }
        loadingbar.Hide();
    }
예제 #6
0
    // Start Coroutine of reading the points from the OFF file and creating the meshes
    IEnumerator loadOFF(string _file)
    {
        //string path = dPath;
        string result = _file;

        // Read file
        //Debug.Log(path);
        //if (path.Contains("://"))
        //      {
        //	WWW www = new WWW(path);
        //          yield return www;
        //          Debug.Log(www.error);
        //          result = www.text;
        //}
        //else
        //	result = System.IO.File.ReadAllText(path);


        Debug.Log(result);
        StringReader sr = new StringReader(result);

        sr.ReadLine();                           // OFF
        string[] buffer = sr.ReadLine().Split(); // nPoints, nFaces

        numPoints = int.Parse(buffer[0]);
        points    = new Vector3[numPoints];
        widths    = new float[numPoints];
        pointsDir = new Quaternion[numPoints];

        colors   = new Color[numPoints];
        minValue = new Vector3();

        for (int i = 0; i < numPoints; i++)
        {
            buffer = sr.ReadLine().Split();

            if (!invertYZ)
            {
                points[i] = new Vector3(float.Parse(buffer[0]) - 1.9f, float.Parse(buffer[1]), float.Parse(buffer[2]));
            }
            else
            {
                points[i] = new Vector3(float.Parse(buffer[0]) - 1.9f, float.Parse(buffer[2]), float.Parse(buffer[1]));
            }

            if (buffer.Length >= 6)
            {
                colors[i] = new Color(int.Parse(buffer[3]) / 255.0f, int.Parse(buffer[4]) / 255.0f, int.Parse(buffer[5]) / 255.0f);
            }
            else
            {
                colors[i] = Color.cyan;
            }

            if (points[i].magnitude > maxLenght)
            {
                maxLenght = points[i].magnitude;
            }

            if (buffer.Length >= 7)
            {
                widths[i] = float.Parse(buffer[6]);                // / 100f;
            }
            else
            {
                widths[i] = 0f;
            }

            pointsDir[i].w = i;


            // GUI
            if (i % Mathf.FloorToInt(numPoints / 20) == 0)
            {
                loadingBar.Show("Cargando Puntos", (i * 1f) / numPoints);
                yield return(null);
            }
        }
        loadingBar.Hide();

        //Scale and recenter
        yield return(StartCoroutine(ReshapePoints()));

        yield return(StartCoroutine(OrderPoints()));

        // Instantiate Point Groups
        numPointGroups = Mathf.CeilToInt(numPoints * 1.0f / limitPoints * 1.0f);

        pointCloud = new GameObject(filename);

        for (int i = 0; i < numPointGroups - 1; i++)
        {
            InstantiateMesh(i, limitPoints);

            if (i % 10 == 0)
            {
                loadingBar.Show("Generando Malla", (i * 1f) / numPoints);
                yield return(null);
            }
        }
        loadingBar.Hide();

        InstantiateMesh(numPointGroups - 1, numPoints - (numPointGroups - 1) * limitPoints);
        //pointCloud.transform.LookAt(pointCloud.transform.position + Vector3.up);

        //Store PointCloud
        //UnityEditor.PrefabUtility.CreatePrefab ("Assets/Resources/PointCloudMeshes/" + filename + ".prefab", pointCloud);

        loaded = true;
    }
예제 #7
0
    // Start Coroutine of reading the points from the OFF file and creating the meshes
    IEnumerator LoadOFF()
    {
        DebugUnity.Log(file);
        StringReader sr = new StringReader(file);

        sr.ReadLine();         // OFF
        string firstLine = sr.ReadLine().Replace("# ", "");

        string[] buffer = firstLine.Split(); // nPoints, nFaces
        //Debug.Log("\"" + buffer[0] + "\"");
        numPoints = int.Parse(buffer[0]);
        points    = new Vector3[numPoints];
        widths    = new float[numPoints];
        pointsDir = new Quaternion[numPoints];

        colors   = new Color[numPoints];
        minValue = new Vector3();

        for (int i = 0; i < numPoints; i++)
        {
            buffer = sr.ReadLine().Split();

            if (!invertYZ)
            {
                points[i] = new Vector3(float.Parse(buffer[0]) - 1.9f, float.Parse(buffer[1]), float.Parse(buffer[2]));
            }
            else
            {
                points[i] = new Vector3(float.Parse(buffer[0]) - 1.9f, float.Parse(buffer[2]), float.Parse(buffer[1]));
            }

            if (buffer.Length >= 6)
            {
                colors[i] = new Color(int.Parse(buffer[3]) / 255.0f, int.Parse(buffer[4]) / 255.0f, int.Parse(buffer[5]) / 255.0f);
            }
            else
            {
                colors[i] = Color.cyan;
            }

            if (points[i].magnitude > maxLenght)
            {
                maxLenght = points[i].magnitude;
            }

            if (buffer.Length >= 7)
            {
                widths[i] = float.Parse(buffer[6]);                // / 100f;
            }
            else
            {
                widths[i] = 0f;
            }

            pointsDir[i].w = i;


            // GUI
            if (i % Mathf.FloorToInt(numPoints / 20) == 0)
            {
                loadingBar.Show("Cargando Puntos", (i * 1f) / numPoints);
                yield return(null);
            }
        }
        loadingBar.Hide();

        //Scale and recenter
        yield return(StartCoroutine(ReshapePoints()));

        yield return(StartCoroutine(OrderPoints()));

        // Instantiate Point Groups
        numPointGroups = Mathf.CeilToInt(numPoints * 1.0f / limitPoints * 1.0f);

        pointCloud = new GameObject("OFF");

        for (int i = 0; i < numPointGroups - 1; i++)
        {
            InstantiateMesh(i, limitPoints);

            if (i % 10 == 0)
            {
                loadingBar.Show("Generando Malla", (i * 1f) / numPoints);
                yield return(null);
            }
        }
        loadingBar.Hide();

        InstantiateMesh(numPointGroups - 1, numPoints - (numPointGroups - 1) * limitPoints);
        //pointCloud.transform.LookAt(pointCloud.transform.position + Vector3.up);
        //Store PointCloud
        //UnityEditor.PrefabUtility.CreatePrefab ("Assets/Resources/PointCloudMeshes/" + filename + ".prefab", pointCloud);

        //pointCloud.transform.rotation = Quaternion.Euler(90f, 0f, 0f) * Quaternion.identity;

        loaded = true;
    }