本文整理汇总了C#中UnityEngine.AudioClip.GetInstanceID方法的典型用法代码示例。如果您正苦于以下问题:C# AudioClip.GetInstanceID方法的具体用法?C# AudioClip.GetInstanceID怎么用?C# AudioClip.GetInstanceID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.AudioClip
的用法示例。
在下文中一共展示了AudioClip.GetInstanceID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportAudio
internal void ExportAudio(AudioClip audio)
{
if (audio == null) return;
string path = AssetDatabase.GetAssetPath(audio.GetInstanceID());
if (exportedAudio.Contains(path)) return;
exportedAudio.Add(path);
string dest = Path.Combine(AudioDir, Path.GetFileName(path));
try
{
File.Copy(path, dest, true);
}
catch (UnityException ue)
{
Debug.Log(ue.ToString());
throw;
}
}
示例2: ExportAudio
public void ExportAudio(AudioClip asset)
{
string assetPath = AssetDatabase.GetAssetPath(asset.GetInstanceID());
string exportPath = Path.Combine(Path.Combine(assets.AudioDir, ".."), assetPath.Replace("Assets/", ""));
if (!Directory.Exists(Path.GetDirectoryName(exportPath)))
{
Directory.CreateDirectory(Path.GetDirectoryName(exportPath));
}
File.Copy(assetPath, exportPath, true);
//Debug.Log("Exported Audio asset to " + exportPath);
}
示例3: ImportInfo
public ImportInfo( AudioClip clip )
{
Clip = clip;
Path = AssetDatabase.GetAssetPath( clip.GetInstanceID() );
GUID = AssetDatabase.AssetPathToGUID( Path );
Importer = AssetImporter.GetAtPath( Path ) as AudioImporter;
if( GATEditorUtilities.IsInResources( Path ) )
{
PathInResources = GATEditorUtilities.PathInResources( Path );
}
else if( GATEditorUtilities.IsInStreamingAssets( Path ) )
{
PathInResources = GATEditorUtilities.PathInStreamingAssets( Path );
System.IO.Path.ChangeExtension( PathInResources, System.IO.Path.GetExtension( Importer.assetPath ) );
IsStreamingAsset = true;
}
}
示例4: PlayRandom
/// <summary>
/// Plays the given audio clip with a random pitch and volume as defined in the settings given.
/// </summary>
public AudioSource PlayRandom(AudioClip clip, Vector3 pos, AudioClipSettings settings)
{
if (settings.SingleInstance && m_activeClips.Count > 0)
{
// Search the list for the matching audio clip
for (int i = 0; i < m_activeClips.Count; i++)
{
if (m_activeClips[i].clip.GetInstanceID() == clip.GetInstanceID())
{
// Found and overlap period not over yet
// End the function and skip the audio clip
if (m_activeClips[i].time < settings.OverlapThreshold && m_activeClips[i].isPlaying)
{
return null;
}
// Found and overlap is over
else
{
m_activeClips.RemoveAt(i);
break;
}
}
}
}
// Retrieve unused audio source from pool
GameObject newSound = m_AudioSources.New(pos);
var cb = newSound.GetComponent<CustomBehaviour>();
var audSrc = cb.GetAudioSource;
// Randomization
float randomPitch = UnityEngine.Random.Range(settings.MinPitch, settings.MaxPitch);
float randomVol = UnityEngine.Random.Range(settings.MinVolume, settings.MaxVolume);
newSound.transform.position = pos;
audSrc.clip = clip;
audSrc.pitch = randomPitch;
audSrc.volume = randomVol;
audSrc.outputAudioMixerGroup = settings.MixerGroup;
if (settings.SingleInstance)
{
m_activeClips.Add(audSrc);
}
newSound.SetActive(true);
Timing.RunCoroutine(StoreClip(cb), Segment.SlowUpdate);
return audSrc;
}