Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UniRx;
- using UnityEngine;
- using Zenject;
- public class TestDebug : IInitializable
- {
- private float WidthHalf => Screen.width * 0.5f;
- private float HeightHalf => Screen.height * 0.5f;
- private Rect UpperLeftRect => new Rect(0, HeightHalf, WidthHalf, HeightHalf);
- private Rect UpperRightRect => new Rect(WidthHalf, HeightHalf, WidthHalf, HeightHalf);
- private Rect BottomLeftRect => new Rect(0, 0, WidthHalf, HeightHalf);
- private Rect BottomRightRect => new Rect(WidthHalf, 0, WidthHalf, HeightHalf);
- private bool UpperLeft => UpperLeftRect.Contains(Input.mousePosition);
- private bool UpperRight => UpperRightRect.Contains(Input.mousePosition);
- private bool BottomLeft => BottomLeftRect.Contains(Input.mousePosition);
- private bool BottomRight => BottomRightRect.Contains(Input.mousePosition);
- public void Initialize()
- {
- var clickStream = Observable.EveryUpdate()
- .Where(_ => Input.GetMouseButtonUp(0));
- var upperLeftStream = clickStream.Where(_ => UpperLeft);
- var upperRightStream = clickStream.Where(_ => UpperRight);
- var bottomLeftStream = clickStream.Where(_ => BottomLeft);
- var bottomRightStream = clickStream.Where(_ => BottomRight);
- upperLeftStream.Subscribe(l => Debug.Log(nameof(upperLeftStream)));
- upperRightStream.Subscribe(l => Debug.Log(nameof(upperRightStream)));
- bottomLeftStream.Subscribe(l => Debug.Log(nameof(bottomLeftStream)));
- bottomRightStream.Subscribe(l => Debug.Log(nameof(bottomRightStream)));
- }
- }
Add Comment
Please, Sign In to add comment