Example #1
0
    public void OnBtnFinish()
    {
        string fullname = mInputFilename.GetComponent <InputField>().text;

        string[] splits = fullname.Split(new char[2] {
            '\\', '/'
        });
        string filename = splits[splits.Length - 1];
        Song   song     = new Song();

        song.DBID          = -1;
        song.BPM           = mCustomTP.BPM;
        song.StartTime     = mCustomTP.StartTime;
        song.EndTime       = mCustomTP.EndTime;
        song.FilePath      = String.Join("/", splits, 0, splits.Length - 1) + "/";
        song.FileNameNoExt = splits[splits.Length - 1].Split('.')[0];
        song.Title         = mInputTitle.GetComponent <InputField>().text;
        song.Artist        = mInputArtist.GetComponent <InputField>().text;
        song.StarCount     = 0;
        song.UserID        = Setting.Inst().UserName;
        song.Bars          = mCustomTP.ExportToBars();
        song.BarCount      = song.Bars.Length;

        byte[] buf = Utils.Serialize(song);
        File.WriteAllBytes(Application.persistentDataPath + "/" + song.FileNameNoExt + ".bytes", buf);

        if (mEditTarget != null)
        {
            mEditTarget.GetComponent <ItemDisplay>().SongInfo = song;
        }
        else
        {
            GameObject  musicListObj = GameObject.Find("btnList").GetComponent <MainCategory>().SelectView;
            MusicLoader loader       = musicListObj.GetComponentInChildren <MusicLoader>();
            loader.AddNewSong(song);
        }
        MainCategory mainCate = GameObject.Find("btnList").GetComponent <MainCategory>();

        mainCate.OnClickButton();

        ResetAll();
        mCustomTP.ReleaseAll();
    }