When a ScriptableObject asset that has either:
- An
[AssetIcon] attribute is on a member that returns an AudioClip.
- An
[AssetIcon] attribute is on a method that accepts an IAssetPreview as a parameter.
And when:
- The user double-clicks the
ScriptableObject asset.
- The user right-clicks the
ScriptableObject asset and selects 'Open'.
- The user selects the
ScriptableObject asset and presses return.
The action associated with the ScriptableObject is invoked.
Playing an AudioClip should also be configurable. Every play of the AudioClip should allow the user to vary the following:
- The volume of the
AudioClip.
- The pitch of the
AudioClip.
- How long the
AudioClip should be played.
Examples
An AudioClip should be quickly and easily associated with the ScriptableObject.
using AssetIcons;
using UnityEngine;
[CreateAssetMenu]
public class ItemInformation : ScriptableObject
{
[AssetIcon]
public AudioClip PickupSound;
}
An IAssetPreview should be used to allow the user to have more control over how the ScriptableObject icon is previewed.
using AssetIcons;
using UnityEngine;
[CreateAssetMenu]
public class ItemInformation : ScriptableObject
{
public AudioClip PickupSound;
[AssetIcon]
public void OnPreviewAsset(IAssetPreview assetPreview)
{
assetPreview.PlaySound(PickupSound, 0.5f, 0.95f);
}
}
When a
ScriptableObjectasset that has either:[AssetIcon]attribute is on a member that returns anAudioClip.[AssetIcon]attribute is on a method that accepts anIAssetPreviewas a parameter.And when:
ScriptableObjectasset.ScriptableObjectasset and selects 'Open'.ScriptableObjectasset and presses return.The action associated with the
ScriptableObjectis invoked.Playing an
AudioClipshould also be configurable. Every play of theAudioClipshould allow the user to vary the following:AudioClip.AudioClip.AudioClipshould be played.Examples
An
AudioClipshould be quickly and easily associated with theScriptableObject.An
IAssetPreviewshould be used to allow the user to have more control over how theScriptableObjecticon is previewed.