Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Edit Audio #246

Closed
xp4xbox opened this issue Nov 22, 2018 · 8 comments
Closed

Feature: Edit Audio #246

xp4xbox opened this issue Nov 22, 2018 · 8 comments

Comments

@xp4xbox
Copy link

xp4xbox commented Nov 22, 2018

It would be very useful if there was a plugin to edit the audio like there is for textures.

@jack980517
Copy link

#91

@xp4xbox
Copy link
Author

xp4xbox commented Nov 24, 2018

Still would be very useful. That method is cumbersome,

@xp4xbox
Copy link
Author

xp4xbox commented Nov 24, 2018

@DerPopo I think it would be nice if you could add the source code on github. So others can contribute.

As far as I know, this is the best tool for editing compiled assets.

@xp4xbox
Copy link
Author

xp4xbox commented Nov 25, 2018

@jack980517 Can you give me a more in-depth way of doing that method?

@jack980517
Copy link

jack980517 commented Nov 29, 2018

  • Install Unity Editor. If you already have a post-5.x version of Unity Editor installed, it should work. If you don't have it or your version doesn't work, use the same version that was used to build the asset file you want to modify.
  • Create a Unity project.
  • Import the modified audio file into your project.
  • With the audio file selected in the editor, open the drop-down menu in the bottom-right corner, create an asset bundle with any name, and select it. That would include this audio file in an asset bundle.
  • Create a folder called Editor in the Assets folder, create a C# script called CreateAssetBundles in the Editor folder, copy the code for building asset bundles from this official manual page into this C# script file, and use the newly appeared menu item to build the asset bundle.
  • If the original asset bundle (not the one you've built) only contains a single audio file:
    • Replace its .resource file with yours.
    • Use UABE to edit the AudioClip asset in the original asset bundle, and change the size value to the size of the new .resource file. (The offset should be 0 in both files.)
  • If not (note that I haven't tested this second case, and all this is just speculation that should work in theory):
    • Append the contents of your .resource file to the original one with a hex editor or the following command: copy /b original.resource+your.resource new.resource (Backup original.resource and rename new.resource to original.resource obviously) This method wastes disk space since it leaves the original audio data in the .resource file unused, but replacing the original data would be way more cumbersome.
    • Use UABE to edit the AudioClip asset in the original asset bundle. Change the offset value to the original size of the .resource file (i.e. before you appended the data), and the size value to the size of the .resource file you've built.
  • Done. It should work now.

@Arfra-token
Copy link

@jack980517 Hi,guy.I also encountered the problem of modifying the AudioClip file.If the original asset bundle contains not only one audio file,is there any possible way to modify a particular AudioClip file?

@DerPopo
Copy link
Collaborator

DerPopo commented Jun 23, 2019

@Arfra-token I think the manual jack980517 provided should cover it. Generate a .resource file with the new audio through Unity Editor, append it to the original .resource file and fix the original AudioClip (the one you want to modify) by updating the offset and size values (using the unmodified .resource file size in bytes as the offset and the size of your own .resource file from Unity Editor in bytes as the size).

@Arfra-token
Copy link

@DerPopo Thanks a lot! That's quite useful. According to the steps you provided, I have successfully modified the audio I want.
Besides,is it possible to modify an audio file just like a Texture2D file,which don't have to add additional . resource files?It would be much more convenient if everything can be packed into a . exe file.
Looking forward to your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants