Пример #1
0
    public Sprite GetImage()
    {
        Texture2D texture = null;
        Sprite    sprite  = null;

        if (GameObject.Find("LocalResources") == null)
        {
            texture = Resources.Load <Texture>("Music/" + path + "/image") as Texture2D;
            if (texture != null)
            {
                sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
            }
        }
        else
        {
            Debug.Log("aclip:" + path + "/image");
            GameObject     gameObject     = GameObject.Find("LocalResources");
            LocalResources localResources = gameObject.GetComponent <LocalResources>();

            Debug.Log("local" + localResources);
            texture = (UnityEngine.Texture)localResources.GetLoadFile(path + "/image") as Texture2D;
            Debug.Log("texture" + texture);
            sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
        }
        return(sprite);
    }
Пример #2
0
    public AudioClip GetAudioClip()
    {
        AudioClip aClip;

        if (GameObject.Find("LocalResources") == null)
        {
            aClip = Resources.Load <AudioClip>("Music/" + path + "/music");
        }
        else
        {
            Debug.Log("aclip:" + path + "/music");
            GameObject     gameObject     = GameObject.Find("LocalResources");
            LocalResources localResources = gameObject.GetComponent <LocalResources>();
            aClip = (AudioClip)localResources.GetLoadFile(path + "/music");
            Debug.Log(aClip);
        }
        return(aClip);
    }
Пример #3
0
    protected override void Load()
    {
        SimpleMusicData musicData;
        MusicInf        inf;

        MusicDTO.EditData data;
        MusicOldDTO       oldData;
        GameObject        gameObject     = GameObject.Find("LocalResources");
        LocalResources    localResources = gameObject.GetComponent <LocalResources>();
        string            folder         = "/music";

#if UNITY_EDITOR
        folder = "/resources/music";
#endif

        if (System.IO.Directory.Exists(@Application.dataPath + folder))
        {
            string[] directories = System.IO.Directory.GetDirectories(@Application.dataPath + "/resources/music", "*");
            string   json;
            for (int i = 0; i < directories.Length; i++)
            {
                // id,pathを読み込む
                MusicListItemJson item;
                item    = new MusicListItemJson();
                item.id = startId + i;

                if (System.IO.Directory.Exists(directories[i]))
                {
                    if (System.IO.File.Exists(directories[i] + "/info.json"))
                    {
                        json = (string)localResources.GetLoadFile(directories[i] + "/info");
                        inf  = JsonUtility.FromJson <MusicInf>(json);
                    }
                    else
                    {
                        break;
                    }
                    if (System.IO.File.Exists(directories[i] + "/music.wav"))
                    {
                        item.path = directories[i];
                    }
                    else if (System.IO.File.Exists(directories[i] + "/music.mp3"))
                    {
                        item.path = directories[i];
                    }
                    else
                    {
                        break;
                    }
                    if (System.IO.File.Exists(directories[i] + "/score.json"))
                    {
                        json = (string)localResources.GetLoadFile(directories[i] + "/score");

                        // 譜面情報を読み込む
                        if (inf.score_ver == 1)
                        {
                            data = JsonUtility.FromJson <MusicDTO.EditData>(json);
                            MusicDTOFormatter musicDTOFormatter = new MusicDTOFormatter(item, inf, data);
                            musicData = musicDTOFormatter.ToSimpleMusicData();
                        }
                        else if (inf.score_ver == 0)
                        {
                            oldData = JsonUtility.FromJson <MusicOldDTO>(json);
                            MusicDTOFormatter musicDTOFormatter = new MusicDTOFormatter(item, inf, oldData);
                            musicData = musicDTOFormatter.ToSimpleMusicData();
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                    musicDataList.Add(musicData);
                }
            }
        }
    }