Scripting
Fabric.Player.API.PostEvent
Posts an audio event on a given game object.
void PostEvent
(
UInt64 FabricInstanceId
, UInt64 fpkId
, [MarshalAs(UnmanagedType.LPStr)]string eventName
, EventAction eventAction
, int gameObjectId
, int playingId = -1
, EventCallback callback = null
);
Click to copy
- UInt64 FabricInstanceID - The ID of Fabric.Player.FabricPlayer.Instance.fabricPlayerInstanceId
- UInt64 fpkID - The ID of the fpk the event is stored within.
- string eventName - the name of the event
- EventAction eventAction - an enum that determines what type of action is associated with this event (i.e. Play, Stop, etc.)
- int gameObjectID - The ID of the game object sending this event. Use the Id stored in the AudioObject component.
Example:
const string eventName = "play_music";
UInt64 fpkID = FPKInfo.GetFPKID("Music");
Fabric.Player.FabricAudioObject audioObject = gameObject.GetComponent<Fabric.Player.FabricAudioObject>();
int audioObjectID = audioObject.ID;
Fabric.Player.API.PostEvent(Fabric.Player.FabricPlayer.Instance.fabricPlayerInstanceId, fpkID, eventName, Fabric.Native.EventAction.PlaySound, audioObjectID);
Click to copy
Fabric.Player.API.SetParameter
Sets the value of a parameter on a game object (locally scoped).
void SetParameter
(
UInt64 FabricInstanceId
, UInt64 fpkId
, [MarshalAs(UnmanagedType.LPStr)]string eventName
, [MarshalAs(UnmanagedType.LPStr)]string parameterName
, int gameObjectId
, float value
, int playingId = -1
);
Click to copy
- UInt64 FabricInstanceID - The ID of Fabric.Player.FabricPlayer.Instance.fabricPlayerInstanceId
- UInt64 fpkID - The ID of the fpk the event is stored within.
- string parameterName - The name of the parameter
- int gameObjectID - The ID of the game object sending this event. Use the Id stored in the AudioObject component.
- float value - The value of the parameter
Example:
const string parameterName = "footstep_volume";
UInt64 fpkID = FPKInfo.GetFPKID("Footsteps");
Fabric.Player.FabricAudioObject audioObject = gameObject.GetComponent<Fabric.Player.FabricAudioObject>();
int audioObjectID = audioObject.ID;
Fabric.Player.API.SetParameter(Fabric.Player.FabricPlayer.Instance.fabricPlayerInstanceId, fpkID, parameterName, audioObjectID, 0.5f);
Click to copy
Fabric.Player.API.SetGlobalParameter
Sets the value of a parameter (global scope).
void SetGlobalParameter
(
UInt64 FabricInstanceId
, [MarshalAs(UnmanagedType.LPStr)]string parameterName
, float value
);
Click to copy
- UInt64 FabricInstanceID - The ID of Fabric.Player.FabricPlayer.Instance.fabricPlayerInstanceId
- string parameterName - The name of the parameter
- float value - The value of the parameter
Example:
void SwitchMusic()
{
if (isIntenseLayerPlaying)
{
Fabric.Player.API.SetGlobalParameter(Fabric.Player.FabricPlayer.Instance.fabricPlayerInstanceId, "music_layer", 0);
isIntenseLayerPlaying = false;
}
else
{
Fabric.Player.API.SetGlobalParameter(Fabric.Player.FabricPlayer.Instance.fabricPlayerInstanceId, "music_layer", 100);
isIntenseLayerPlaying = true;
}
}
Click to copy
Fabric.Player.API.SetGlobalSwitch
Sets the value of a switch (global scope).
void SetGlobalSwitch
(
UInt64 FabricInstanceId
, [MarshalAs(UnmanagedType.LPStr)]string globalSwitchName
, [MarshalAs(UnmanagedType.LPStr)]string switchName
);
Click to copy
- UInt64 FabricInstanceID - The ID of Fabric.Player.FabricPlayer.Instance.fabricPlayerInstanceId
- string globalSwitchName - The name of the global switch container
- string switchValue - The value of the switch
Example:
private void SwitchAmbience()
{
if (isFirstAmbience)
{
Fabric.Player.API.SetGlobalSwitch(Fabric.Player.FabricPlayer.Instance.fabricPlayerInstanceId, "s_time", "Night");
isFirstAmbience = false;
}
else
{
Fabric.Player.API.SetGlobalSwitch(Fabric.Player.FabricPlayer.Instance.fabricPlayerInstanceId, "s_time", "Afternoon");
isFirstAmbience = true;
}
}
Click to copy
0 Comments
Add your comment