- Home /
Audio clip, import, Inspector - default settings?
NOTE -- since about 2014, it's possible to select more than one AudioClip at the one time.
So, this is only of historic interest, fortunately...
You take a sound file, abc.wav, and drop it in your assets folder
Click on the file in the PROJECT panel, look at the INSPECTOR
You can change the values, LoadType etc. But they always begin with the values shown in the image here.
This hurts if you are dropping 100s of sounds in to your assets folder!
(1) is there a way to change the default shown in the image?
(2) is there any way to highlight 100 items in your PROJECT panel, and change the settings all at once?
(I looked on the asset store for a "mass changer," presumably an editor script, unfortunately could not find one.)
Thanks!
Later - I know nothing about editor scripting, but I cobbled this together. Please ignore my hideous c# ! This may help someone in the future ... cheers! You can very easily extend this to other properties in the AudioImporter, or indeed other importers.
////////////////////////////////////// filename AudioSettingsAEN.cs
using UnityEngine;
using UnityEditor;
// audio settings ......... appliquer en masse
// select as many as you want in PROJECT pane (even using folders)
// then use these menu items in the editor.
// you can trivially add more functions as needed, using
// this reference: /Documentation/ScriptReference/AudioImporter.html
// Drop this file in your Assets/Editor/ folder
public class AudioSettingsAEN : ScriptableObject
{
[MenuItem ("Utilities/AudioSettingsAEN/change all selected to: 2D sound")]
static void __2D()
{
int k=0;
int tot=0;
foreach (AudioClip ac in GetSelectedAudio())
{
string path = AssetDatabase.GetAssetPath( ac );
AudioImporter ai = AssetImporter.GetAtPath(path) as AudioImporter;
if ( ai.threeD != false )
{
ai.threeD = false;
++k;
}
++tot;
AssetDatabase.ImportAsset( path );
}
Debug.Log("Changed " +k+ " out of " +tot+ " for you.");
// add reporting code like that in each case if useful to you
}
[MenuItem ("Utilities/AudioSettingsAEN/change all selected to: 3D sound")]
static void __3D()
{
foreach (AudioClip ac in GetSelectedAudio())
{
string path = AssetDatabase.GetAssetPath( ac );
AudioImporter ai = AssetImporter.GetAtPath(path) as AudioImporter;
ai.threeD = true;
AssetDatabase.ImportAsset( path );
}
}
/////////////////////////////////////////
[MenuItem ("Utilities/AudioSettingsAEN/change all selected to: Stream from disc")]
static void __stream()
{
foreach (AudioClip ac in GetSelectedAudio())
{
string path = AssetDatabase.GetAssetPath( ac );
AudioImporter ai = AssetImporter.GetAtPath(path) as AudioImporter;
ai.loadType = AudioImporterLoadType.StreamFromDisc;
AssetDatabase.ImportAsset( path );
}
}
[MenuItem ("Utilities/AudioSettingsAEN/change all selected to: Uncompressed live")]
static void __decomp()
{
foreach (AudioClip ac in GetSelectedAudio())
{
string path = AssetDatabase.GetAssetPath( ac );
AudioImporter ai = AssetImporter.GetAtPath(path) as AudioImporter;
ai.loadType = AudioImporterLoadType.DecompressOnLoad;
AssetDatabase.ImportAsset( path );
}
}
/////////////////////////////////////////
[MenuItem ("Utilities/AudioSettingsAEN/change all selected to: comp default (156000)")]
static void __k156()
{
foreach (AudioClip ac in GetSelectedAudio())
{
string path = AssetDatabase.GetAssetPath( ac );
AudioImporter ai = AssetImporter.GetAtPath(path) as AudioImporter;
ai.compressionBitrate = 156000;
AssetDatabase.ImportAsset( path );
}
}
[MenuItem ("Utilities/AudioSettingsAEN/change all selected to: comp 128000")]
static void __k128()
{
foreach (AudioClip ac in GetSelectedAudio())
{
string path = AssetDatabase.GetAssetPath( ac );
AudioImporter ai = AssetImporter.GetAtPath(path) as AudioImporter;
ai.compressionBitrate = 128000;
AssetDatabase.ImportAsset( path );
}
}
[MenuItem ("Utilities/AudioSettingsAEN/change all selected to: comp 96000")]
static void __k96()
{
foreach (AudioClip ac in GetSelectedAudio())
{
string path = AssetDatabase.GetAssetPath( ac );
AudioImporter ai = AssetImporter.GetAtPath(path) as AudioImporter;
ai.compressionBitrate = 96000;
AssetDatabase.ImportAsset( path );
}
}
/////////////////////////////////////////
static Object[] GetSelectedAudio()
{
return Selection.GetFiltered( typeof(AudioClip), SelectionMode.DeepAssets );
}
}
///////////////////////////////////////////////////////////////
Unfortunately, multi-object editing isn't supported for Audio yet. It will probably be enabled in Unity 4, but up until now, I've always had to edit each audio-file seperately.
The only way to achieve what you want is to write your own EditorScript. I assume it's not all that hard, because there are specific functions for what you would need. Here's something that might help you:
http://docs.unity3d.com/Documentation/ScriptReference/AssetPostprocessor.OnPreprocessAudio.html
and
http://docs.unity3d.com/Documentation/ScriptReference/AssetPostprocessor.html
Hope I could help you on your way, too bad it's not yet supported by the Unity Editor itsself.
right on Tim, thanks. I cobbled a editor script, I will foist it on the world in an answer here ... cheers
Answer by code-blep · Oct 25, 2012 at 10:43 PM
Hi Fattie. I think this component allows mass changes to component fields: http://u3d.as/content/bovine-labs/extended-inspector/2rY just in case your Uber script doesn't work out ;)
Your answer
Follow this Question
Related Questions
Inspector Panel Broken 2 Answers
Project view script settings not being used 0 Answers
How can I regenerate the an objects icon in the Project window? 0 Answers
My Project view is broken Help! 0 Answers
Jump back to Prefab in Project view when selected there 0 Answers