コード例 #1
0
    void Update()
    {
        if (Input.GetMouseButton(0) && _card_Logic.isMouseOver == true)
        {
            Vector2 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            _card_Transform.position = pos;
        }
        else
        {
            _card_Transform.position = Vector2.MoveTowards(_card_Transform.position, new Vector2(0, 0), _card_MovingSpeed);
        }

        // Right Side
        if (_card_Transform.position.x > 2)
        {
            _card_SpriteRenderer.color = Color.green;

            if (!Input.GetMouseButton(0))
            {
                _card_Logic.InduceRight();
            }
        }
        // Left side
        else if (_card_Transform.position.x < -2)
        {
            _card_SpriteRenderer.color = Color.red;

            if (!Input.GetMouseButton(0))
            {
                _card_Logic.InduceLeft();
            }
        }
        // Neutral
        else
        {
            _card_SpriteRenderer.color = Color.white;
        }
    }