LipSync Documentationbeta
Welcome to the new online documentation for LipSync Pro and Lite.
This area will be updated with new information and tutorials when available.
Welcome to the new online documentation for LipSync Pro and Lite.
This area will be updated with new information and tutorials when available.
Blend Systems are classes that inherit from the built-in RogoDigital.Lipsync.BlendSystem class.
They exist as hidden components on a GameObject that has LipSync or Eye Controller added to it, and they
are managed automatically.
The purpose of Blend Systems is to allow LipSync to be as flexible as possible by not actually doing
the animation itself. In terms of the Blend Shape Blend System, instead of LipSync directly storing
references to Skinned Mesh Renderers or setting the values of Blend Shapes, it simply passes the blendable's
index and desired value to the Blend System to handle.
A Blendable is any aspect of the Character's representation that the Blend System can alter. In the
Blend Shape Blend System they are Blend Shapes, in the Sprite Blend System they are layer/sprite
combinations stored in the Sprite Manager component.
Part of the power of Blend Systems is the fact that anyone can write their own. This allows LipSync to
work with almost any character imaginable - anything from basic sprites and 3D models, to crazy
light or particle-based systems.
In order to function as a Blend System, your script needs to inherit from RogoDigital.Lipsync.BlendSystem.
This base class has a number of virtual methods you can override in order to implement your Blend
System's functionality. While you can write all this yourself, the simplest way to get started is to
use the provided boilerplate code.
Just right-click somewhere in the Project panel, and choose Create > LipSync Pro > Empty BlendSystem.
public override void OnEnable () {
base.OnEnable();
}
In this method, you can do any initialization your Blend System requires. You should also set the value
of blendableDisplayName
, blendableDisplayNamePlural
, noBlendablesMessage
, and notReadyMessage
here. The two DisplayName variables are used in place of 'Blendable'/'Blendables'
in the inspector, e.g. 'Blend Shape' or 'Sprite'.blendRangeLow
& blendRangeHigh
to
re-map the minimum and maximum values on the blendable sliders in the Pose Editor. These are set to 0
and 100 respectively by default.base.OnEnable()
after setting these variables to ensure that the Blend
System works correctly.
AddBlendable(int index, float startingValue)
if necessary and then return the list.
public override string[] GetBlendables () {
if (!isReady || characterMesh == null)
return null;
bool setInternal = false;
string[] blendShapes = new string[characterMesh.sharedMesh.blendShapeCount];
if (blendableCount == 0) setInternal = true;
for (int a = 0; a < blendShapes.Length; a++) {
blendShapes[a] = characterMesh.sharedMesh.GetBlendShapeName(a) + " (" + a.ToString() + ")";
if (setInternal) AddBlendable(a, characterMesh.GetBlendShapeWeight(a));
}
return blendShapes;
}
SetInternalValue(int index, float value)
.GetBlendableValue(int blendable)
is called. This helps with preventing
conflicts when multiple scripts attempt to change the same value.
public override void SetBlendableValue (int blendable, float value) {
if (!isReady || characterMesh == null)
return;
characterMesh.SetBlendShapeWeight(blendable, value);
SetInternalValue(blendable, value);
foreach (SkinnedMeshRenderer renderer in optionalOtherMeshes) {
if (blendable < renderer.sharedMesh.blendShapeCount) renderer.SetBlendShapeWeight(blendable, value);
}
}