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 jamal-dahbur · Aug 17, 2015 at 02:19 AM · c#unity 5assetsmemory

Delete sound assets during gameplay?

I'm making a game where the user dynamically adds objects and saves them to come back to, I currently have it all figured out after many a nights tinkering with serializing, well I have got how to save a recording to a wav file and how to call that back during gameplay, but how do I delete that file? Let's say a user makes a song and wants to delete it after a couple of days to make space, I'd like to delete the sounds from his device as well as the serialized strings to stop the game from being a memory consuming monster, any ideas on how to go about this? Or any links that explain it? It must be during gameplay so Editor scripts for sure won't work.

Comment
Add comment · Show 3
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 jamal-dahbur · Aug 17, 2015 at 04:15 AM 0
Share

Thank you! Ill give it a try

avatar image itsharshdeep · Aug 17, 2015 at 05:14 AM 0
Share

I think by some method you need to over right the file with the same name. Like you have created a file name '1.wav' and then you are going on with increment ( i.e. 2,3,4,...N). now you have to delete 1 so now you have to recreate a file named 1.wav so that the new updated file should be over write the old file.

I dont know any other solution. :(

avatar image jamal-dahbur · Aug 17, 2015 at 01:28 PM 0
Share

I was thinking about doing that actually if I can't get File.Delete to work (which so far I haven't been able to), any ideas getyour411? I'm using System.IO and I put File.Delete(file.path + file Name) in my code and I even debug the file path and file name to make sure it's matching but alas no avail, it won't delete, though it's debuging the right file path.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by NeverHopeless · Aug 17, 2015 at 06:31 AM

You can try like this to delete the sound file created:

 System.IO.File.Delete(yourFilePath);
Comment
Add comment · Show 4 · 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 jamal-dahbur · Aug 17, 2015 at 01:29 PM 0
Share

I'm trying to, I'm using System.IO and I put File.Delete(file.path + file Name) in my code and I even debug the file path and file name to make sure it's matching but it won't delete, though it's debuging the right file path.

avatar image NeverHopeless · Aug 17, 2015 at 01:35 PM 0
Share

There are few conditions when the Delete function is expected to work but it appears never working. Please check if you have any of these conditions:

http://stackoverflow.com/questions/2025482/file-delete-not-deleting-the-file

http://stackoverflow.com/questions/6391711/how-to-delete-a-file-after-checking-whether-it-exists

avatar image jamal-dahbur · Aug 17, 2015 at 01:40 PM 0
Share

No that's not it, do you think maybe it's because I'm deleting the game object after deleting the sound assets associated with it, and the game object is destroyed and code stops running because of that? I'm trying a coroutine now with a yield return wait for seconds(3f) but that still isn't working

avatar image jamal-dahbur · Aug 17, 2015 at 08:52 PM 0
Share

I finally got it to work, turns out I wasn't putting + ".wav" after the file path, so it was never really finding it, I know, I am indeed a dumb ass, but I'm learning lol. Thanks for your help!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Help me with this json code please 1 Answer

How do i cast mesh like a linerenderer? 0 Answers

Why is the memory used of a level going up when entering the level from another level? 1 Answer


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