- Home /
Passing Java String to C# for use in Wwise Post Event = Fail
Using the technique for passing values between Javascript and C# here: Unity3D: JavaScript->C# or C#->JavaScript Access
I am passing a string from an animation Event to the Javascript as noted here: Unity: Using Animation Events
Java:
public var theValue : String = "";
public var SendSoundString : String;
function SoundEvent (theValue : String) {
SendSoundString = '"' + theValue + '"';
Debug.Log ("SoundEvent called with a value of " + '"' + theValue + '"');
C#:
public Java_SoundString_Send jsSoundStringScript;
void Awake()
{
//Get the JavaScript component
jsSoundStringScript = this.GetComponent<Java_SoundString_Send>();//Don't forget to place the 'Java_SoundString_Send' file inside the 'Standard Assets' folder
}
void PlayFootstepSound()
{
AkSoundEngine.PostEvent(jsSoundStringScript.SendSoundString, gameObject);
Debug.Log ("PlayFootstep Received SendSoundString called with a theValue of " + jsSoundStringScript.SendSoundString);
}
I can get the debug log to print the properly formatted string for use in the following Wwise PostEvent call, but it will not post the Event or play the sound.
Wwise Event call that works:
AkSoundEngine.PostEvent("Play_Hello", gameObject);
Wwise Event call that doesn't work:
AkSoundEngine.PostEvent(jsSoundStringScript.SendSoundString, gameObject);
PlayFootstepSound Received SendSoundString called with a theValue of "Play_Hello"
Is it possible that this method of passing a string to the PostEvent call is not compatible?
Is there a different way to format (prepare) the string for use by the PostEvent call?
Admittedly fumbling in the dark a bit with all of this black magik, any help would be appreciated.
Thanks!
Same problem here. Seems that PostEvent won't accept any string as-is.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
c# string script to javascirpt? 1 Answer
Play music trough scenes 0 Answers
Audio problems, how to turn up and down specifik audio sources? 1 Answer