Last active
August 29, 2015 14:23
-
-
Save komo91/c7cd1c285388ec5c7a07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine;//使うライブラリの宣言 | |
using System.Collections; | |
//MonoBehaviourを継承したPaintItクラスの宣言 | |
public class PaintIt : MonoBehaviour { | |
private bool isPainted = false;//真偽値 | |
private float timeFromPaint = 0.0f;//触れた時間を値として入れる | |
public float resetTime = 1.0f; | |
public Color color; | |
int count = 0; | |
// Use this for initialization | |
void Start () { | |
} | |
// Update is called once per frame | |
void Update () { | |
// 一度色づけられるとresetTime 間は保持されて、その後色が戻る | |
if ( isPainted ) | |
{ | |
timeFromPaint += Time.deltaTime; //deltaTimeは経過時間を表す | |
if ( timeFromPaint > resetTime ) | |
{ | |
//ここで指定された色に変える | |
GetComponent<Renderer>().material.color = new Color( 1.0f, 1.0f, 1.0f ); | |
isPainted = false; | |
} | |
} | |
} | |
public void setColor() | |
{ | |
// 色はインスペクタ上から指定可能 | |
GetComponent<Renderer> ().material.color = color; | |
timeFromPaint = 0.0f; | |
isPainted = true;//trueのとき色が変わる | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment