using UnityEngine;
using System.Collections;
public class Lightintensity : MonoBehaviour {
public float lastStrong1; //求めるライト強度(0.0~8.0) public float lastStrong2; //求めるライト強度(0.0~8.0) private float lightStrong; //現在ライト強度 public float fadeSpeed; //フェードのスピード public int intflg = 1; // Use this for initialization void Start () { GetComponent<Light>().intensity = 0.5f; } // Update is called once per frame void Update () { if(intflg == 0) { FadeOut(); } else if(intflg == 2) { FadeIn(); } } void FadeOut() { if (lightStrong >= lastStrong1) { lightStrong -= Time.deltaTime * fadeSpeed; GetComponent<Light>().intensity = lightStrong; } if (lightStrong <= lastStrong1) { intflg = 2; } } void FadeIn() { if (lightStrong <= lastStrong2) { lightStrong += Time.deltaTime * fadeSpeed; GetComponent<Light>().intensity = lightStrong; } if(lightStrong >= lastStrong2) { intflg = 1; } }
}
UnityのC#スクリプトです。
ライトを使って同じシーン上でフェードインフェードアウトするときに、このプログラムを使っているのですが、一回目は一瞬で動くのでいいんですが、二回目以降からプレイヤーが移動してからフェードインフェードアウトをしてしまうのです。しかも二回目以降はフェードインフェードアウトがゆっくりになっています。二回目以降も一瞬でフェードインフェードアウトするにはどうしたらいいですか?
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/06/18 02:12
2015/06/18 02:25