Hello,
I was looking for how to export the animation as a video file that I made in AnyPortrait. I'm currently want to use this feature for sound editing in the video editor software. Because it is easier to do it since I'm better at video editor softwares such as Premiere Pro, After Effects or Audition. I'm going to make a sound editing for a whole animation, and then render as .mp3 or .wav then re-import to Unity to use in the game. Probably it would better if I create new Gameobject for sounds since I have multiple animation clips in one portrait.
Or is there better/easier solution for sound editing inside Unity without exporting the animation as video file? I'm open to suggestions.
Also I might be use this video export feature for not only game animation creation, maybe other things as well such as wallpaper animation etc...
Thanks.
Hello,
Yes, it solved the one last error.
Thank you!!
Hi!
It's nice that the problem is almost solved.
The reason for that one error would be the same.
At the moment of activating GameObject, apPortrait's Initialize() function is not called yet, so error 1 occurs. (In the next frame, it works normally since Initialize() is called.)
Our recommendation is that when activating a GameObject containing apPortrait, you manually call apPortrait's Initialize() function. Then the above 1 error will also disappear.
Check out the tutorial link we attached in the previous answer.
Thank you.
Hello,
I understood the reason for the +999 error now. This error was caused by the fact that the CIASoundCheck(); code checked it repeatedly in the update and in my scene, the portrait gameobject was deactive when the game was first started (Because when the player clicks the button, the portrait object becomes active). I reduced the error count to 1 by typing the following code into Update ().
Yet, there is one error left.
There's something related with 992. line in original AP script or my script causing this.
Thank you.
Hi!
We have received your e-mail and analyzed the script.
We didn't find any problems in the script you sent.
Assuming the member properties are well set in the Unity Scene, our conclusion is that your script will work without much weirdness.
The error that occurred in the "IsPlaying" function you reported is that the "Initialize" function of apPortrait was not called, or it was stopped due to an error.
Since apPortrait's "Initialize" function is called automatically, the related errors do not occur continuously.
If so, what we suspect is that the initialization was aborted due to an unknown error while executing the "Initialize" function.
There may be other error logs in the console window other than those caused by "IsPlaying". Check it out.
(Of course we have other possibilities in mind, but in most cases it was caused by a bad initialization.)
First, take a look at the following tutorial related to initialization, and check if there is anything weird about the console window and your scene.
https://rainyrizzle.github.io/en/AdvancedManual/AD_InitializeScript.html
Even when the scene is not loaded, similar problems can occur in various cases such as duplicating, creating, deleting, and referencing GameObjects.
Please take this into account.
It was difficult for us to find problems within your script file. Therefore, we recommend that you check the other scripts, scene settings, game execution process, etc. overall.
If you can give us additional information, we can help you further.
We look forward to resolving this issue.
Thanks.
P.S. Today's work is over, so if you ask more questions, we can give you the next answer tomorrow.
Hello,
I sent the file via mail. Sorry for bothering you :c
You help me a lot, thank you for that!
Hi!
When we check the errors you have written, it is mainly seen as errors that occur when the code is written incorrectly related to "Initialization".
But since we don't know the full code, we don't know exactly where and why the error occurs.
It is difficult to determine the cause of these types of errors through just a few pieces of code.
If possible, please write down the full code or send the file to our email. ( contactrainyrizzle@gmail.com )
There are several ways to smoothly convert the audio, and the most commonly used method is through "Coroutine".
We've browsed web pages with some sample code to help you.
It can be a bit difficult for you if you haven't tried coroutine code before.
However, the code is not long, so it would be nice to give it a try.
(The script contents of the web pages below are similar.)
https://www.codegrepper.com/code-examples/whatever/fade+in+fade+out+sound+unity
https://forum.unity.com/threads/fade-out-audio-source.335031/
https://gamedevbeginner.com/how-to-fade-audio-in-unity-i-tested-every-method-this-ones-the-best/
Thanks.
Hello,
The size of the "gameAudio" array is not less than 5, that's why I don't get the problem.
This time, I made a new function to stop all sounds gameAudio. I'm calling this method before new audio play.
And debug error log changed (Now it gives error on AnyPortrait script).
Here's the 992. line:
As I said, the game and sounds run smoothly and it seems unnecessary error/false alarm to me. But I thought it would better if I let you know :)
Thank you.
As you can see from the error log in the console window, the index is out of range of the array.
The size of the "gameAudio" array is less than 5, so an error occurs.
(The error of 157 lines seems to be caused by fewer than 4 smaller arrays.)
In the Inspector, check that the gameAudio array has 5 or more items properly set, and find out if there is code in your code that unnecessarily initializes this array.
You can solve the problem through messages in the console window.
Here's the 157. line in my code:
Hello,
It solved my problem, thank you!!
Even there is no problem in the game, Console Debug gives +999 errors. I don't get it. Since the game works fine, I can leave it like this. But if you have an idea, I'd like to hear.
ContinuousCheck() is CIASoundCheck() in my code. Just names are different.
Hi!
Through the code you attached, it seems you want to change the audio according to the animation.
When we check your code, there are "code that starts playing two animations sequentially" and "code that continuously checks whether the second clip is playing and changes the audio" in one function.
However, these two codes should not be in a single function because they must be called completely differently.
The former "code that starts animations" is code that is executed only Once.
On the other hand, the latter "code that checks whether to execute animation" is Continuously executed in the Update function and the condition must be checked. (Of course, it cannot be executed after the conditions are satisfied.)
You need to classify your code by considering whether it is code that is executed "Once" or "Continuously". (Very Important!)
We have prepared sample examples similar to your code.
Since it is difficult for us to tell you whether the sound is running or not in a post, we will instead use Debug.Log to show you how the code runs.
(If the image is small, click on it to see the larger image.)
This is a code similar to yours.
Dividing this code into 3 parts is as above.
(1) Initialize the audio sources. This is not very important.
(2) This is a code that plays two animations sequentially using CrossFade and CrossFadeQueued functions.
According to the code above, when you press the A key, "Anim1" and then "Anim2 Loop" will be played.
(3) This part is the code that waits for the second animation "Anim2 Loop" to play and then plays Audio2.
Make sure we write down the Debug.Log.
Let's run the game and check the logs.
When you press the A key, the animation starts, and logs are displayed as above.
Each of the logs means:
(1) Audio sources are initialized.
(2) "Anim1" and "Anim2 Loop" start playing in sequence.
(3) Check whether "Anim2 Loop" is playing.
Here, you can find the problem.
If you keep checking whether the animation is playing or not, the log (3) should not be printed only once!
You can see that this log should be output every frame.
This is because at the time CrossFadeQueued is called, the second animation is waiting, not playing.
Now let's make the "if statement" be executed continuously.
(Click to enlarge the image and you will see the code well.)
(1) Move the original code (2) to a separate new function. In this sample, we created a new function called "ContinuousCheck()" and moved it there.
(3) And in the Update() function, write the ContinuousCheck() function to be called continuously unlike the PlayScene1d() function.
Make sure that one is called "once" when A is pressed, and the other is called every frame of Update regardless of key input.
Now play it, and the second sound will start playing!
Unlike before, "if statement" (which is ContinuousCheck() function) is executed continuously, and you can see that numerous logs are output.
This is because the logs were recorded every frame because it checked the status of the animation clip every frame.
There are so many logs, (1) we made unnecessary logs invisible.
(2) Unlike before, a log indicating that Audio2 was played was output.
Once you've solved your problem, but here's a new problem.
You can hear the second audio source play weird several times over and over again if you write the code above.
If you check the logs, you can see that the function is called to play "Audio 2" every time, even though "Audio 2" is already running.
You need to improve the code so that it "checks to play the animation every frame, and then no longer runs the code once Audio2 has been played".
There are various ways, but let's simply solve it using the bool variable here.
(1) Add a bool variable called "_isAudio2Played". (Default is false)
(2) Add "!_isAudio2Played" condition with "&& (AND)" operator to the conditional statement that checks "Anim2 Loop".
(3) If this conditional statement is executed at least once, switch "_isAudio2Played" to true so that it is not executed later.
Now, this code checks the "Anim2 Loop" animation every frame, and if the conditional statement passes at least once and Audio2 plays, this code will no longer run.
Let's run it again.
Now everything is resolved so "Anim1" and "Audio1" will play together, then "Anim2 Loop" and "Audio2" will start playing.
We actively use "Debug.Log" when we encounter "code not executing problem".
This simple method is very effective in the process of validating the code is running.
It will be of great help in learning how Unity runs.
Thanks.
Hello,
I prepared my sounds and imported into Unity. I change the animation clip with the button. The first 3 scenes (animation clips) have loop animation.But since the 4th clip only needs to play once, (scene1d) is not loop animation. But next scene1e is loop animation.
I used gameobjects instead of using Timeline because I'm going to play only one sound.
(GameAudio has a sound for each animation clip)
Since the 4th animation clip is not looped, I used CrossFadeQueued to automatically transition animation. And it works great! I just couldn't understand how to do the same situation for sound.
I wrote a script like the one below, but the sound does not change when the clip changes. The first sound still continues to play. That's why I wanted your opinion. (It should change it to scene1d.wav => scene1e.wav when plays the queued animation).
scene1d.wav assigned to gameAudio[3] array
scene1e.wav assigned to gameAudio[4] array
Thank you.
Hi!
If you want to add elements such as sound or post-processing to your animation, we recommend using Unity's Timeline feature.
AnyPortrait supports playing in Unity's Timeline.
Using the Timeline, it is also possible to play animations in sequence.
Details can be found at the link below.
https://rainyrizzle.github.io/en/AdvancedManual/AD_Timeline.html
You can also refer to the official documentation for Unity Timeline.
https://unity3d.com/unity/features/editor/art-and-design/timeline
Unity's Timeline system is based on the Mecanim system. Check out how to learn how to play AnyPortrait's animations with Mecanim's Animator first.
https://rainyrizzle.github.io/en/AdvancedManual/AD_Mecanim.html
After applying Unity's Timeline, you can create video files using "Unity Recorder".
However, the sound quality is probably not as good as that of a professional video editing program. Please take this into account.
How to use the Unity Recorder is also written as a tutorial, so you can see it on the page below.
https://rainyrizzle.github.io/en/AdvancedManual/AD_UnityRecorder.html
As an additional tip, when our team makes promotional videos, we do not use the Unity Recorder for high quality and make the video by following the procedure below.
- Build with PC application. It will be rendered with maximum quality. We use "Timeline" or script to control animations and cameras.
- Run the application and take a video with another capture program.
- Edit the captured video using a professional video editing program.
While it is easy to shoot videos with Unity Recorder, professional editing tools are inevitably good to create the highest quality videos. You can choose the method that suits you considering quality and efficiency.
As Unity is recently updating with interest in the video industry, it is expected that higher-quality video production will be possible in the future.
As AnyPortrait also uses the features of Unity, future versions may be able to provide more convenient video recording functions with improved quality.
Thanks.