//エフェクト開始時のコールバック protected override void OnStartEffect(GameObject target, AdvEngine engine, AdvScenarioThread thread) { Camera camera = target.GetComponentInChildren <Camera>(true); ImageEffectBase imageEffect; bool alreadyEnabled; if (!ImageEffectUtil.TryGetComonentCreateIfMissing(imageEffectType, out imageEffect, out alreadyEnabled, camera.gameObject)) { Complete(imageEffect, thread); return; } if (!inverse) { imageEffect.enabled = true; } bool enableAnimation = !string.IsNullOrEmpty(animationName); bool enableFadeStregth = imageEffect is IImageEffectStrength; if (!enableFadeStregth && !enableAnimation) { Complete(imageEffect, thread); return; } if (enableFadeStregth) { IImageEffectStrength fade = imageEffect as IImageEffectStrength; float start = inverse ? fade.Strength : 0; float end = inverse ? 0 : 1; Timer timer = camera.gameObject.AddComponent <Timer>(); timer.AutoDestroy = true; timer.StartTimer( engine.Page.ToSkippedTime(this.time), engine.Time.Unscaled, (x) => { fade.Strength = x.GetCurve(start, end); }, (x) => { if (!enableAnimation) { Complete(imageEffect, thread); } }); } if (enableAnimation) { //アニメーションの適用 AdvAnimationData animationData = engine.DataManager.SettingDataManager.AnimationSetting.Find(animationName); if (animationData == null) { Debug.LogError(RowData.ToErrorString("Animation " + animationName + " is not found")); Complete(imageEffect, thread); return; } AdvAnimationPlayer player = camera.gameObject.AddComponent <AdvAnimationPlayer>(); player.AutoDestory = true; player.EnableSave = true; player.Play(animationData.Clip, engine.Page.SkippedSpeed, () => { Complete(imageEffect, thread); }); } }
protected override void OnStartEffect(GameObject target, AdvEngine engine, AdvScenarioThread thread) { Camera camera = target.GetComponentInChildren <Camera>(true); float start, end; ImageEffectBase imageEffect = null; IImageEffectStrength effectStrength = null; if (string.IsNullOrEmpty(ruleImage)) { bool alreadyEnabled; bool ruleEnabled = camera.gameObject.GetComponent <RuleFade>(); if (ruleEnabled) { camera.gameObject.SafeRemoveComponent <RuleFade>(); } ImageEffectUtil.TryGetComonentCreateIfMissing(ImageEffectType.ColorFade.ToString(), out imageEffect, out alreadyEnabled, camera.gameObject); effectStrength = imageEffect as IImageEffectStrength; ColorFade colorFade = imageEffect as ColorFade; if (inverse) { //画面全体のフェードイン(つまりカメラのカラーフェードアウト) // start = colorFade.color.a; start = (ruleEnabled) ? 1 : colorFade.color.a; end = 0; } else { //画面全体のフェードアウト(つまりカメラのカラーフェードイン) //colorFade.Strengthで、すでにフェードされているのでそちらの値をつかう start = alreadyEnabled ? colorFade.Strength : 0; end = this.color.a; } colorFade.enabled = true; colorFade.color = color; } else { bool alreadyEnabled; camera.gameObject.SafeRemoveComponent <ColorFade>(); ImageEffectUtil.TryGetComonentCreateIfMissing(ImageEffectType.RuleFade.ToString(), out imageEffect, out alreadyEnabled, camera.gameObject); effectStrength = imageEffect as IImageEffectStrength; RuleFade ruleFade = imageEffect as RuleFade; ruleFade.ruleTexture = engine.EffectManager.FindRuleTexture(ruleImage); ruleFade.vague = vague; if (inverse) { start = 1; end = 0; } else { start = alreadyEnabled ? ruleFade.Strength : 0; end = 1; } ruleFade.enabled = true; ruleFade.color = color; } Timer timer = camera.gameObject.AddComponent <Timer>(); timer.AutoDestroy = true; timer.StartTimer( engine.Page.ToSkippedTime(this.time), engine.Time.Unscaled, (x) => { effectStrength.Strength = x.GetCurve(start, end); }, (x) => { OnComplete(thread); if (inverse) { imageEffect.enabled = false; imageEffect.RemoveComponentMySelf(); } }); }