Skip to content

Commit

Permalink
modify animator sample to change the state to toggle lipsync.
Browse files Browse the repository at this point in the history
  • Loading branch information
hecomi committed Dec 28, 2022
1 parent 4154939 commit 3a98ff1
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 7 deletions.
16 changes: 16 additions & 0 deletions Assets/uLipSync/Samples/09. Animator/09. Animator.unity
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,22 @@ MonoBehaviour:
minVolume: -2.5
maxVolume: -1.5
smoothness: 0.05
--- !u!114 &496503036
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 496503018}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 02dee2b7eb95d45668264ba2f49040fd, type: 3}
m_Name:
m_EditorClassIdentifier:
toggleKey: 32
animator: {fileID: 0}
triggerON: On
triggerOff: Off
--- !u!850595691 &1359427199
LightingSettings:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1101 &-3725065209149386101
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Off
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 749076179739798450}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.2
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &-1105067801183814876
AnimatorState:
serializedVersion: 6
Expand All @@ -10,7 +35,8 @@ AnimatorState:
m_Name: Blend Tree
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_Transitions:
- {fileID: -3725065209149386101}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
Expand Down Expand Up @@ -65,6 +91,18 @@ AnimatorController:
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
- m_Name: On
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
- m_Name: Off
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
Expand Down Expand Up @@ -261,17 +299,47 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: -1105067801183814876}
m_Position: {x: 290, y: 110, z: 0}
m_Position: {x: 340, y: 110, z: 0}
- serializedVersion: 1
m_State: {fileID: 749076179739798450}
m_Position: {x: 340, y: 250, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: -48, y: -144, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 730, y: 370, z: 0}
m_EntryPosition: {x: 110, y: 110, z: 0}
m_ExitPosition: {x: 110, y: 250, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: -1105067801183814876}
--- !u!1102 &749076179739798450
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Smile
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 8858868643535408785}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 06b76ba9895174fc19d91c361e7c911b, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &7558474624444292480
AnimatorState:
serializedVersion: 6
Expand Down Expand Up @@ -353,3 +421,28 @@ BlendTree:
m_UseAutomaticThresholds: 1
m_NormalizedBlendValues: 1
m_BlendType: 4
--- !u!1101 &8858868643535408785
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: On
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -1105067801183814876}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.2
m_TransitionOffset: 0
m_ExitTime: 0.1
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
4 changes: 1 addition & 3 deletions Assets/uLipSync/Samples/09. Animator/mouth only mask.mask
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ AvatarMask:
m_Weight: 0
- m_Path: mesh_root/hairband
m_Weight: 0
- m_Path: mesh_root/kutu
- m_Path: mesh_root/Leg
m_Weight: 0
- m_Path: mesh_root/Shirts
m_Weight: 0
Expand All @@ -341,5 +341,3 @@ AvatarMask:
m_Weight: 0
- m_Path: mesh_root/uwagi_BK
m_Weight: 0
- m_Path: mesh_root/uwagi_perker
m_Weight: 0
46 changes: 46 additions & 0 deletions Assets/uLipSync/Samples/09. Animator/uLipSyncAnimatorToggle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using UnityEngine;

namespace uLipSync
{

public class uLipSyncAnimatorToggle : MonoBehaviour
{
public KeyCode toggleKey = KeyCode.Space;
public Animator animator;
public string triggerON = "On";
public string triggerOff = "Off";
bool _isOn = true;

void Awake()
{
if (animator) return;

animator = GetComponent<Animator>();
}

void Update()
{
if (Input.GetKeyDown(toggleKey))
{
Toggle();
}
}

void Toggle()
{
_isOn = !_isOn;

if (!animator) return;

if (_isOn)
{
animator.SetTrigger(triggerON);
}
else
{
animator.SetTrigger(triggerOff);
}
}
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3a98ff1

Please sign in to comment.