-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add audio task and audio sample scene
- Loading branch information
Showing
18 changed files
with
2,585 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
Assets/Virtual Agents Framework/Runtime/Scripts/FundamentalAgentTasks/AgentAudioTask.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using UnityEngine; | ||
|
||
namespace i5.VirtualAgents.AgentTasks | ||
{ | ||
public class AgentAudioTask : AgentBaseTask, ISerializable | ||
{ | ||
/// <summary> | ||
/// The audio to be played | ||
/// </summary> | ||
public AudioClip Audio; | ||
|
||
/// <summary> | ||
/// The audio source which plays the audio | ||
/// </summary> | ||
public AudioSource AgentAudioSource; | ||
|
||
/// <summary> | ||
/// Creates a new audio task | ||
/// </summary> | ||
/// <param name="audio">The audio to be played</param> | ||
public AgentAudioTask(AudioClip audio, int priority = 0) | ||
{ | ||
Audio = audio; | ||
} | ||
|
||
/// <summary> | ||
/// Starts the audio task | ||
/// </summary> | ||
/// <param name="agent">The agent which should execute the movement task</param> | ||
public override void StartExecution(Agent agent) | ||
{ | ||
base.StartExecution(agent); | ||
AgentAudioSource = agent.GetComponent<AudioSource>(); | ||
AgentAudioSource.clip = Audio; | ||
AgentAudioSource.Play(); | ||
} | ||
|
||
/// <summary> | ||
/// Finish the task | ||
/// </summary> | ||
public override void StopExecution() | ||
{ | ||
base.StopExecution(); | ||
AgentAudioSource.Stop(); | ||
} | ||
|
||
public void Serialize(SerializationDataContainer serializer) | ||
{ | ||
} | ||
|
||
public void Deserialize(SerializationDataContainer serializer) | ||
{ | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Assets/Virtual Agents Framework/Runtime/Scripts/FundamentalAgentTasks/AgentAudioTask.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
Assets/Virtual Agents Framework/Samples/Audio Sample/AgentAudioController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using i5.VirtualAgents.ScheduleBasedExecution; | ||
using System.Collections.Generic; | ||
using i5.VirtualAgents.AgentTasks; | ||
using UnityEngine; | ||
|
||
namespace i5.VirtualAgents.Examples | ||
{ | ||
public class AgentAudioController : SampleScheduleController | ||
{ | ||
[SerializeField] private List<AudioClip> audioClip; | ||
protected override void Start() | ||
{ | ||
base.Start(); | ||
AgentAudioTask audioTask = new AgentAudioTask(audioClip[0]); | ||
taskSystem.ScheduleTask(audioTask); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/Virtual Agents Framework/Samples/Audio Sample/AgentAudioController.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
23 changes: 23 additions & 0 deletions
23
Assets/Virtual Agents Framework/Samples/Audio Sample/Antikythera.mp3.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
Assets/Virtual Agents Framework/Samples/Audio Sample/Audio Sample.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.