using UnityEngine;
using System.Collections;

public class DoubleInputMouse
{
	public string _keyName;
	public float repeatTime = 0.3f;

	protected bool _isFirst = false;
	protected float _startTime = 0.0f;

    public DoubleInputMouse(string keyName)
    {
        _keyName = keyName;
    }

	public void Update()
	{
        if (Input.GetButtonDown(_keyName) && !_isFirst)
        {
            _startTime = Time.time;
            _isFirst = true;
        }
        else if (Input.GetButtonDown(_keyName) && _isFirst && (Time.time - _startTime < repeatTime))
        {
            _isFirst = false;
            _startTime = 0.0f;
            Messenger.Broadcast("DoubleClick_MouseKey", _keyName);
            Debug.Log("isPress");
        }
	}
}


public class DoubleInputKey
{
    public KeyCode _keyCode;
    public float repeatTime = 0.3f;

    protected bool _isFirst = false;
    protected float _startTime = 0.0f;

    public DoubleInputKey(KeyCode keyCode)
    {
        _keyCode = keyCode;
    }

    public void Update()
    {
        if (Input.GetKeyDown(_keyCode) && !_isFirst)
        {
            _startTime = Time.time;
            _isFirst = true;
        }
        else if (Input.GetKeyDown(_keyCode) && _isFirst && (Time.time - _startTime < repeatTime))
        {
            _isFirst = false;
            _startTime = 0.0f;
            Debug.Log("isPress");
            Messenger.Broadcast("DoubleClick_Key", _keyCode);
        }
    }
}

2011/09/30 17:07 2011/09/30 17:07
Posted by Junios

트랙백 보낼 주소 : http://junios.net/tc/trackback/291

<< PREV : [1] : ... [4] : [5] : [6] : [7] : [8] : [9] : [10] : [11] : [12] : ... [187] : NEXT >>

BLOG main image
Junios World by Junios

카테고리

전체 (187)
주저리 (60)
Tips (8)
적어놓기 (7)
Hacking (1)
Programming (110)
(1)

최근에 받은 트랙백

글 보관함

달력

«   2012/05   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Total : 121508
Today : 20 Yesterday : 60