반응형
Notice
Recent Posts
Recent Comments
«   2024/03   »
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
Archives
Today
Total
관리 메뉴

Do Something IT

UniRx Mouse Drag 본문

Unity3D

UniRx Mouse Drag

아낙시만더 2018. 11. 15. 02:25
반응형
using UnityEngine;
using InputInfo;

using UniRx;
using UniRx.Triggers;

public class Player : MonoBehaviour
{
    private GameObject _mainCamera;
    private ReadOnlyReactiveProperty InputData { get; set; }

    // Use this for initialization
    void Start()
    {
        var _mainCamera = Camera.main.gameObject;

        var downStream = (_mainCamera).UpdateAsObservable().Where(_ => Input.GetMouseButtonDown(0));
        var upStream = (_mainCamera).UpdateAsObservable().Where(_ => Input.GetMouseButtonUp(0));
        var dragStream = (_mainCamera).UpdateAsObservable()
            .SkipUntil(downStream)
            .TakeUntil(upStream)
            .Select(_ => Input.mousePosition)
            .RepeatUntilDestroy(_mainCamera);

              dragStream.Subscribe(hitInfo =>
        {
          
            Debug.Log("Drag>>>>>{" + hitInfo + "}");
        });
    }
}


반응형
Comments