Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Due to no changes CubismUpdateController to add new type Controllers #34

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions Assets/Live2D/Cubism/Framework/CubismEyeBlinkController.cs
Expand Up @@ -75,6 +75,11 @@ public void Refresh()
_hasUpdateController = (GetComponent<CubismUpdateController>() != null);
}

/// <summary>
/// Called by cubism update controller. Needs to invoke OnLateUpdate on Editing.
/// </summary>
public bool NeedsUpdateOnEditing => false;

/// <summary>
/// Called by cubism update controller. Updates controller.
/// </summary>
Expand Down
112 changes: 6 additions & 106 deletions Assets/Live2D/Cubism/Framework/CubismUpdateController.cs
Expand Up @@ -50,128 +50,28 @@ public void Refresh()
// Clear delegate.
Delegate.RemoveAll(OnLateUpdate, null);

ICubismUpdatable renderController = null;
ICubismUpdatable maskController = null;
ICubismUpdatable fadeController = null;
ICubismUpdatable poseController = null;
ICubismUpdatable expressionController = null;
ICubismUpdatable eyeBlinkController = null;
ICubismUpdatable mouthController = null;
ICubismUpdatable harmonicMotionController = null;
ICubismUpdatable lookController = null;

// Find cubism components.
// Set delegate.
var components = model.GetComponents<ICubismUpdatable>();
foreach(var component in components)
{
if (component.GetType() == typeof(CubismRenderController))
{
renderController = component;
}
else if (component.GetType() == typeof(CubismMaskController))
{
maskController = component;
}
#if UNITY_EDITOR
else if (!Application.isPlaying)
#if UNITY_EDITOR
if (!Application.isPlaying && !component.NeedsUpdateOnEditing)
{
continue;
}
#endif
else if (component.GetType() == typeof(CubismFadeController))
{
fadeController = component;
}
else if (component.GetType() == typeof(CubismPoseController))
{
poseController = component;
}
else if (component.GetType() == typeof(CubismExpressionController))
{
expressionController = component;
}
else if (component.GetType() == typeof(CubismEyeBlinkController))
{
eyeBlinkController = component;
}
else if (component.GetType() == typeof(CubismMouthController))
{
mouthController = component;
}
else if (component.GetType() == typeof(CubismHarmonicMotionController))
{
harmonicMotionController = component;
}
else if(component.GetType() == typeof(CubismLookController))
{
lookController = component;
}

OnLateUpdate += component.OnLateUpdate;
}

#if UNITY_EDITOR
// Application is playing.
if(Application.isPlaying)
if (Application.isPlaying)
{
#endif
// Cache parameter save restore.
_parameterStore = model.GetComponent<CubismParameterStore>();

// Add fade controller late update.
if (fadeController != null)
{
OnLateUpdate += fadeController.OnLateUpdate;
}

// Add pose controller late update.
if (poseController != null)
{
OnLateUpdate += poseController.OnLateUpdate;
}

// Add expression controller late update.
if (expressionController != null)
{
OnLateUpdate += expressionController.OnLateUpdate;
}

// Add eye blink controller late update.
if (eyeBlinkController != null)
{
OnLateUpdate += eyeBlinkController.OnLateUpdate;
}

// Add mouth controller late update.
if (mouthController != null)
{
OnLateUpdate += mouthController.OnLateUpdate;
}

// Add harmonic motion controller late update.
if (harmonicMotionController != null)
{
OnLateUpdate += harmonicMotionController.OnLateUpdate;
}

// Add look controller late update.
if (lookController != null)
{
OnLateUpdate += lookController.OnLateUpdate;
}
#if UNITY_EDITOR
}
#endif

// Add render late update.
if (renderController != null)
{
OnLateUpdate += renderController.OnLateUpdate;
}

// Add mask controller late update.
if (maskController != null)
{
OnLateUpdate += maskController.OnLateUpdate;
}
}


Expand Down
Expand Up @@ -94,6 +94,11 @@ private void StartExpression()
_playingExpressions.Add(palyingExpression);
}

/// <summary>
/// Called by cubism update controller. Needs to invoke OnLateUpdate on Editing.
/// </summary>
public bool NeedsUpdateOnEditing => false;

/// <summary>
/// Called by cubism update manager.
/// </summary>
Expand Down
Expand Up @@ -77,6 +77,11 @@ public void Refresh()
_hasUpdateController = (GetComponent<CubismUpdateController>() != null);
}

/// <summary>
/// Called by cubism update controller. Needs to invoke OnLateUpdate on Editing.
/// </summary>
public bool NeedsUpdateOnEditing => false;

/// <summary>
/// Called by cubism update controller. Updates controller.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Assets/Live2D/Cubism/Framework/ICubismUpdatable.cs
Expand Up @@ -12,6 +12,7 @@ namespace Live2D.Cubism.Framework
/// </summary>
public interface ICubismUpdatable
{
bool NeedsUpdateOnEditing { get; }
void OnLateUpdate();
}
}
5 changes: 5 additions & 0 deletions Assets/Live2D/Cubism/Framework/LookAt/CubismLookController.cs
Expand Up @@ -133,6 +133,11 @@ public void Refresh()
_hasUpdateController = (GetComponent<CubismUpdateController>() != null);
}

/// <summary>
/// Called by cubism update controller. Needs to invoke OnLateUpdate on Editing.
/// </summary>
public bool NeedsUpdateOnEditing => false;

/// <summary>
/// Called by cubism update controller. Updates controller.
/// </summary>
Expand Down
Expand Up @@ -89,6 +89,11 @@ private void Refresh()
}
}

/// <summary>
/// Called by cubism update controller. Needs to invoke OnLateUpdate on Editing.
/// </summary>
public bool NeedsUpdateOnEditing => false;

/// <summary>
/// Called by cubism update controller. Updates controller.
/// </summary>
Expand Down
Expand Up @@ -76,6 +76,11 @@ public void Refresh()
_hasUpdateController = (GetComponent<CubismUpdateController>() != null);
}

/// <summary>
/// Called by cubism update controller. Needs to invoke OnLateUpdate on Editing.
/// </summary>
public bool NeedsUpdateOnEditing => false;

/// <summary>
/// Called by cubism update controller. Updates controller.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions Assets/Live2D/Cubism/Framework/Pose/CubismPoseController.cs
Expand Up @@ -212,6 +212,11 @@ private void SavePartOpacities()
}
}

/// <summary>
/// Called by cubism update controller. Needs to invoke OnLateUpdate on Editing.
/// </summary>
public bool NeedsUpdateOnEditing => false;

/// <summary>
/// Called by cubism update manager. Updates controller.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions Assets/Live2D/Cubism/Rendering/CubismRenderController.cs
Expand Up @@ -449,6 +449,11 @@ private void UpdateOpacity()
}
}

/// <summary>
/// Called by cubism update controller. Needs to invoke OnLateUpdate on Editing.
/// </summary>
public bool NeedsUpdateOnEditing => true;

/// <summary>
/// Called by cubism update controller. Applies billboarding.
/// </summary>
Expand Down
Expand Up @@ -147,6 +147,11 @@ private void ForceRevive()
}
}

/// <summary>
/// Called by cubism update controller. Needs to invoke OnLateUpdate on Editing.
/// </summary>
public bool NeedsUpdateOnEditing => true;

/// <summary>
/// Called by cubism update controller. Updates <see cref="Junktions"/>.
/// </summary>
Expand Down