Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: wetcircuit on July 19, 2023, 08:16:00 AM

Title: How to convert FsmObject (audioClip) to get audioClip.length?
Post by: wetcircuit on July 19, 2023, 08:16:00 AM
Hi, I'm trying to read the length (time) of an FsmObject variable which is an audioclip.

The audioclip doesn't exist in the project, it's generated by a 3rd-party text-to-speech, which I am loading directly into the FsmObject variable (in my custom action).

In the same action, I am trying to get the length of the generated audio.... I am struggling how to convert the FsmObject.Value into a Unity audioClip, so I can get audioClip.length

               _audioClip = audioSpeech.Value;
               length.Value = _audioClip.length;


my error: error CS0266: Cannot implicitly convert type 'UnityEngine.Object' to 'UnityEngine.AudioClip'. An explicit conversion exists (are you missing a cast?)

How do I convert?
Title: Re: How to convert FsmObject (audioClip) to get audioClip.length?
Post by: wetcircuit on July 19, 2023, 11:27:34 AM
found it!

               _audioClip = audioSpeech.Value as AudioClip;
               length.Value = _audioClip.length;