Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
950 B

//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: Unparents this object and optionally destroys it after the sound
// has played
//
//=============================================================================
using UnityEngine;
using System.Collections;
namespace Valve.VR.InteractionSystem
{
//-------------------------------------------------------------------------
public class SoundDeparent : MonoBehaviour
{
public bool destroyAfterPlayOnce = true;
private AudioSource thisAudioSource;
//-------------------------------------------------
void Awake()
{
thisAudioSource = GetComponent<AudioSource>();
}
//-------------------------------------------------
void Start()
{
// move the sound object out from under the parent
gameObject.transform.parent = null;
if ( destroyAfterPlayOnce )
Destroy( gameObject, thisAudioSource.clip.length );
}
}
}