/// <summary> /// Refresh delegate manager. /// </summary> public void Refresh() { var model = this.FindCubismModel(); // Fail silently... if (model == null) { return; } // Clear delegate. Delegate.RemoveAll(OnLateUpdate, null); // Set delegate. var components = model.GetComponents <ICubismUpdatable>(); var sortedComponents = new List <ICubismUpdatable>(components); CubismUpdateExecutionOrder.SortByExecutionOrder(sortedComponents); foreach (var component in sortedComponents) { #if UNITY_EDITOR if (!Application.isPlaying && !component.NeedsUpdateOnEditing) { continue; } #endif OnLateUpdate += component.OnLateUpdate; } #if UNITY_EDITOR if (Application.isPlaying) { #endif _parameterStore = model.GetComponent <CubismParameterStore>(); #if UNITY_EDITOR } #endif }
/// <summary> /// Refresh delegate manager. /// </summary> public void Refresh() { var model = this.FindCubismModel(); // Fail silently... if (model == null) { return; } // 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; // Find cubism components. 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) { 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; } } #if UNITY_EDITOR // Application is playing. 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; } #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; } }