playMaker

Author Topic: How to convert FsmObject (audioClip) to get audioClip.length?  (Read 962 times)

wetcircuit

  • Full Member
  • ***
  • Posts: 158
    • wetcircuit.com
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?
« Last Edit: July 19, 2023, 08:20:00 AM by wetcircuit »

wetcircuit

  • Full Member
  • ***
  • Posts: 158
    • wetcircuit.com
Re: How to convert FsmObject (audioClip) to get audioClip.length?
« Reply #1 on: July 19, 2023, 11:27:34 AM »
found it!

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