Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: laynardo on May 22, 2016, 06:43:32 PM
-
hi,
I have a playmaker script, with a text box input. I want to call a text string in there, but there isn't an option in this particular action. How should I approach this?
-
Hi Dude,
Can you right click on the action and go edit script. Then post whats inside it.
I think it should be easy enough to edit so that you can use string fsm variables. Just need to see how its setup.
-
using UnityEngine;
using System.Collections;
using Crosstales.RTVoice;
namespace HutongGames.PlayMaker.Actions {
[ActionCategory("Crosstales.RTVoice")]
public class Speak : SpeakBase {
public bool reset;
[Tooltip("Text to speak.")]
public string Text;
[Tooltip("Culture for of the voice (default: empty).")]
public string Culture = "en";
[Tooltip("Index of the voice from the Speaker.VoicesForCulture()-call.")]
public int Voice;
public override void OnEnter() {
// if (GameObject.Find("RTVoice") == null) {
// AddRTVoice();
// }
switch (Mode) {
case SpeakMode.Speak:
Speaker.Speak(Text, AudioSource, Speaker.VoiceForCulture(Culture, Voice), true, Rate, Volume);
break;
case SpeakMode.SpeakNative:
Speaker.SpeakNative(Text, Speaker.VoiceForCulture(Culture, Voice), Rate, Volume);
break;
}
Finish();
}
}
}
// Copyright 2016 www.crosstales.com
-
Cool.
So what is happening is that the script is using String over FsmString. So what you need to do is just replace it.
So String Text becomes FsmString Text.
Then anywhere you see Text, it now becomes Text.Value
I tried to update the script so that is uses FSM's variables. I can't test it but in theory it should work. The only thing that might cause an error, is if the the of the code tries to use the variables directly and is expecting them in non-Fsm form.
But try it and let me know how it goes.
using UnityEngine;
using System.Collections;
using Crosstales.RTVoice;
namespace HutongGames.PlayMaker.Actions {
[ActionCategory("Crosstales.RTVoice")]
public class Speak : SpeakBase {
public bool reset;
[Tooltip("Text to speak.")]
public FsmString Text;
[Tooltip("Culture for of the voice (default: empty).")]
public FsmString Culture = "en";
[Tooltip("Index of the voice from the Speaker.VoicesForCulture()-call.")]
public FsmInt Voice;
public override void OnEnter() {
// if (GameObject.Find("RTVoice") == null) {
// AddRTVoice();
// }
switch (Mode) {
case SpeakMode.Speak:
Speaker.Speak(Text.Value, AudioSource, Speaker.VoiceForCulture(Culture.Value, Voice.Value), true, Rate, Volume);
break;
case SpeakMode.SpeakNative:
Speaker.SpeakNative(Text.Value, Speaker.VoiceForCulture(Culture.Value, Voice.Value), Rate, Volume);
break;
}
Finish();
}
}
}
// Copyright 2016 www.crosstales.com
-
it worked! I emailed it to the dev as well.
-
Sweet.
Glad it worked and that I could help you out.
Good luck with the rest of the project dude.