-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add blendShape recording function to UnityAnimationRecorder
- Loading branch information
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
Unity Runtime Recorder/Scripts/UnityAnimSaver/UnityBlendShapeAnimation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class UnityBlendShapeAnimation { | ||
|
||
public UnityCurveContainer[] curves; | ||
public SkinnedMeshRenderer skinMeshObj; | ||
string[] blendShapeNames; | ||
int blendShapeCount = 0; | ||
public string pathName = ""; | ||
|
||
public UnityBlendShapeAnimation( string hierarchyPath, SkinnedMeshRenderer observeSkinnedMeshRenderer ) { | ||
pathName = hierarchyPath; | ||
skinMeshObj = observeSkinnedMeshRenderer; | ||
|
||
//int blendShapeCount = skinMeshObj.getbl | ||
Mesh blendShapeMesh = skinMeshObj.sharedMesh; | ||
blendShapeCount = blendShapeMesh.blendShapeCount; | ||
|
||
blendShapeNames = new string[blendShapeCount]; | ||
curves = new UnityCurveContainer[blendShapeCount]; | ||
|
||
// create curve objs and add names | ||
for (int i = 0; i < blendShapeCount; i++) { | ||
blendShapeNames [i] = blendShapeMesh.GetBlendShapeName (i); | ||
curves [i] = new UnityCurveContainer ("blendShape." + blendShapeNames [i]); | ||
} | ||
} | ||
|
||
public void AddFrame ( float time ) { | ||
|
||
for (int i = 0; i < blendShapeCount; i++) | ||
curves [i].AddValue (time, skinMeshObj.GetBlendShapeWeight (i)); | ||
|
||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Unity Runtime Recorder/Scripts/UnityAnimSaver/UnityBlendShapeAnimation.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
c800de0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this repository free to use?
also if it is open source can i contribute to it too?
c800de0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@physicsssss yes, everything is open source. Please feel free to contribute!
c800de0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Thanks a lot for the code!
I am new in Unity!
I have two questions:
Will the saved Animationclips be marked as Legacy? I am asking that, because after recording and saving them at runtime, I have to load them at runtime. And that seems to be difficult:
https://forum.unity.com/threads/cannot-load-animation-clip-from-asset-bundle-how-to-set-animation-clip-to-legacy-in-code.483253/
Could you tell me how to set everything up, so that it works?
I put 6 Scripts into my Scriptsfolder: AnimationRecorderHelper, UnityAnimationRecorder, UnityAnimationRecorderEditor, UnityBlendShapeAnimation, UnityCurveContainer, UnityObjectAnimation.
I attached the Unity AnimationRecorder to the Gameobject, that I want to record. A humanoid character (the humanoid character is animated via input from the steamvr htc xrrig. I filled in the Save Path: Assets/StreamingAssets. I chose a filename.
I press play. There is no Error, in the inspector tab "List of Record Obj" appear all bone children of the rig. Everything seems to be allright. I press "q" for start an "w" stop. But then there is no message in the Console about the progress (start recording or stop recording). And there is no saved file in the StreamingAssets folder and no error message.
Would be really great to hear from you, because this is the last unsolved problem of my project.
Thanks a lot!
c800de0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @bstall-sudo
The animation's label (legacy, humanoid) is only used when you importing models. There's no difference when it is a .anim unity animation format. You can try exporting the animation with models and then import again, like is this thread:
When I used "FBX Exporter", I got error message #17
You can try with demo scene and see how it works. And the script is also readable so you may also figuring out the flow with it.
c800de0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, Thanks a lot. I will try that!