Skip to content

Commit

Permalink
Merge pull request #99 from nagatsuki/fix/use-event-handler
Browse files Browse the repository at this point in the history
Fix/use event handler
  • Loading branch information
sh-akira authored Mar 29, 2024
2 parents dff4ee2 + 7d5a5da commit 26c4bd7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 42 deletions.
6 changes: 0 additions & 6 deletions Assets/Scripts/Avatar/DynamicOVRLipSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class DynamicOVRLipSync : OVRLipSyncContextBase

// smoothing amount
public int SmoothAmount = 100;
private GameObject VRMmodel;

public bool EnableLipSync = false;

Expand Down Expand Up @@ -51,11 +50,6 @@ public void SetMicrophoneDevice(string device)
micSelected = true;
}

public void ImportVRMmodel(GameObject vrmmodel)
{
VRMmodel = vrmmodel;
}

// Use this for initialization
void Start()
{
Expand Down
65 changes: 34 additions & 31 deletions Assets/Scripts/Avatar/FaceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,6 @@ public string GetCaseSensitiveKeyName(string upperCase)
return KeyUpperCaseDictionary.ContainsKey(upperCase) ? KeyUpperCaseDictionary[upperCase] : upperCase;
}

public void ImportVRMmodel(GameObject vrmmodel)
{
VRMmodel = vrmmodel;
proxy = null;
InitializeProxy();
}

private void Start()
{
var dict = new Dictionary<BlendShapeKey, float>();
Expand All @@ -121,6 +114,23 @@ private void Start()
CreateAnimation();
}

private void OnEnable()
{
VMCEvents.OnCurrentModelChanged += OnCurrentModelChanged;
}

private void OnDisable()
{
VMCEvents.OnCurrentModelChanged -= OnCurrentModelChanged;
}

private void OnCurrentModelChanged(GameObject model)
{
VRMmodel = model;
proxy = null;
InitializeProxy();
}

private void CreateAnimation()
{
if (animationController == null) animationController = new AnimationController();
Expand Down Expand Up @@ -412,39 +422,32 @@ private void InitializeProxy()
// Update is called once per frame
void Update()
{
if (VRMmodel != null)
if (VRMmodel == null) return;

if (IsSetting == false)
{
if (proxy == null)
if (EnableBlink && ViveProEyeEnabled == false)
{
InitializeProxy();
}
if (IsSetting == false)
{
if (EnableBlink && ViveProEyeEnabled == false)
isReset = false;
if (StopBlink == false)
{
isReset = false;
if (StopBlink == false)
{
if (animationController?.Next() == false)
{//最後まで行ったら値更新のためにアニメーション作り直す
CreateAnimation();
}
if (animationController?.Next() == false)
{//最後まで行ったら値更新のためにアニメーション作り直す
CreateAnimation();
}
}
else
}
else
{
if (isReset == false)
{
if (isReset == false)
{
isReset = true;
animationController?.Reset();
}
isReset = true;
animationController?.Reset();
}

}

AccumulateBlendShapes();
}

AccumulateBlendShapes();
}
}
}
}
5 changes: 0 additions & 5 deletions Assets/Scripts/ControlWPFWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1100,11 +1100,6 @@ public void LoadNewModel(GameObject model)
renderer.updateWhenOffscreen = true;
}

//LipSync
LipSync.ImportVRMmodel(CurrentModel);
//まばたき
faceController.ImportVRMmodel(CurrentModel);

IKManager.Instance.ModelInitialize();

VMCEvents.OnModelLoaded?.Invoke(CurrentModel);
Expand Down

0 comments on commit 26c4bd7

Please sign in to comment.