Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Hydropulse17 · May 25, 2016 at 08:22 AM · windowsfilesfoldersystem.iolocal files

Allow the player to use a custom music library?

I found a GUI file browser that would do what I need if I could figure out how to implement it, but it was awfully complicated to do something that should be fairly simple. Windows already has a file browser, can't I use that? I've seen it done in games before. Just press browse, navigate through windows to the folder you want, select it, and then the game will cycle through the songs in the folder...Or perhaps there's a way I can have a folder that will be present in the install folder of my stand alone that the game will access, and players can add music to that folder? While searching for an answer, I came across something that seemed promising. "Add Using System.IO to the top of your script." I understand what that means, but I don't know what it allows me to do or how.

Ideally, once the user selected his music folder, the first one in the folder would be played through an audio source in the scene, and when it was over, it would access the next file...

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image $$anonymous$$ · Dec 26, 2016 at 02:06 AM 0
Share

Did it help you solve your problems?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Odyssee · May 25, 2016 at 08:42 AM

System.IO is used for actions with folders like System.IO.File.ReadAllBytes

In your case I would rather dig in StreamingAssets http://docs.unity3d.com/Manual/StreamingAssets.html

StreamingAssets is content that is locally placed in a folder close to the executable. But you'll have to import the files, and do some stuff by yourself by code.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by $$anonymous$$ · May 25, 2016 at 08:53 AM

Adding

 using System.IO;

will let you use it's class' methods, which is what you need. Just after a quick search I found out that if you use System.IO, there's a method called

 Directory.GetFiles(string,string) - where 1st string is the path, and the next one is the search pattern.

If I were you, I'd make a list consisting of strings, and then pass all these files (names) to it, then implement it in my custom music player system. I won't write the whole script for you, but you should be starting with something like this:

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 using System.IO;
 
 public class SearchMusic : MonoBehaviour {
     private List<string> Songs = new List<string>();
 
     // Use this for initialization
     void Start () {
         Songs = Directory.GetFiles("path/to/my/music", ".mp3");
     }
     
 }

I didn't test it, but it should give you a list consisting of the names of the songs.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

44 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Windows 8 - Windows.Storage WriteTextAsync exception 0 Answers

File.Move wont work , error. IOException: Win32 IO returned ERROR_ALREADY_EXISTS. Path: 1 Answer

How do i make it so the data and playerprefs and everything necessary in the game is in the exe file? 1 Answer

Asset bundle not load in unity windows application 0 Answers

A way copy my extra files to the Build? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges