Ejemplo n.º 1
0
        private static IEnumerable <SdnFileEntry> LoadAssets(Spriter spriter, string rootFolder, SpriterDotNetBehaviour spriterDotNetBehaviour, bool andAssignAudioClips)
        {
            for (int i = 0; i < spriter.Folders.Length; ++i)
            {
                SpriterFolder folder = spriter.Folders[i];

                for (int j = 0; j < folder.Files.Length; ++j)
                {
                    SpriterFile file = folder.Files[j];
                    string      path = rootFolder;
                    path += "/";
                    path += file.Name;

                    SdnFileEntry entry = new SdnFileEntry
                    {
                        FolderId = folder.Id,
                        FileId   = file.Id
                    };

                    if (file.Type == SpriterFileType.Sound)
                    {
                        spriterDotNetBehaviour.StartCoroutine(GetAudioClip(entry, path, spriterDotNetBehaviour, andAssignAudioClips));
                    }
                    else
                    {
                        entry.Sprite = LoadNewSprite(path);
                    }

                    yield return(entry);
                }
            }
        }
Ejemplo n.º 2
0
        private static IEnumerable <SdnFileEntry> LoadAssets(Spriter spriter, string rootFolder)
        {
            for (int i = 0; i < spriter.Folders.Length; ++i)
            {
                SpriterFolder folder = spriter.Folders[i];

                for (int j = 0; j < folder.Files.Length; ++j)
                {
                    SpriterFile file = folder.Files[j];
                    string      path = rootFolder;
                    path += "/";
                    path += file.Name;

                    SdnFileEntry entry = new SdnFileEntry
                    {
                        FolderId = folder.Id,
                        FileId   = file.Id
                    };

                    if (file.Type == SpriterFileType.Sound)
                    {
                        entry.Sound = ContentLoader.Load <AudioClip>(path);
                    }
                    else
                    {
                        entry.Sprite = ContentLoader.Load <Sprite>(path);
                    }

                    yield return(entry);
                }
            }
        }
Ejemplo n.º 3
0
        private static IEnumerator GetAudioClip(SdnFileEntry entry, string path, SpriterDotNetBehaviour spriterDotNetBehaviour, bool andAssign)
        {
            using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip("file:///" + path, AudioType.WAV))
            {
                yield return(www.SendWebRequest());

                if (www.result == UnityWebRequest.Result.ConnectionError)
                {
                    Debug.Log(www.error);
                }
                else
                {
                    entry.Sound = DownloadHandlerAudioClip.GetContent(www);
                    if (andAssign)
                    {
                        spriterDotNetBehaviour.Animator.SoundProvider.Set(entry.FolderId, entry.FileId, entry.Sound);
                    }
                }
            }
        }