私は cardboard sdk を使用しており、Unity 用の cardboard sdk を使用してオブジェクトを見つめたときに、オブジェクトの色を lerp しようとしています。以下の lerping スクリプトを使用しており、オブジェクトにアタッチすると凝視とは独立して機能しますが、そのバージョンをSetGazedAt内で機能させようとすると機能しません。
以下は、オブジェクトの色を変更するSetGazedAtのコードです。これをどのように置き換えるか、私が持っている「fill」という名前のLerpスクリプトを呼び出すにはどうすればよいでしょうか?
Fill.cs
using UnityEngine;
using System.Collections;
public class Fill : MonoBehaviour {
float lerpTime = 2f;
float currentLerpTime;
//float moveDistance = 5f;
Color startColor = Color.clear;
Color endColor = Color.clear;
public void Start() {
startColor = Color.clear;
//endColor = new Color(0.0f,0.0f,1.0f,0.5f);
}
public void Update() {
//reset when we press spacebar
if (Input.GetKeyDown(KeyCode.Space)) {
currentLerpTime = 0f;
startColor = Color.clear;
endColor = new Color(0.0f,0.0f,1.0f,0.5f);
}
//increment timer once per frame
currentLerpTime += Time.deltaTime;
if (currentLerpTime > lerpTime) {
currentLerpTime = lerpTime;
}
//lerp!
float perc = currentLerpTime / lerpTime;
GetComponent<Renderer>().material.color = Color.Lerp(startColor, endColor, perc);
}
}
Teleport スクリプトの SetGazedAt メソッド
public void SetGazedAt(bool gazedAt) {
GetComponent<Renderer>().material.color = gazedAt ? Color.clear : Color.red;
}