Example #1
0
        private void CursorOnEndDragEvent(LooperCursor cursor, PointerEventData eventData)
        {
            _draggingCursor = null;

            if (OnDragEndEvent != null)
            {
                OnDragEndEvent();
            }
        }
        public void Init(SongSeeker songSeeker)
        {
            _songSeeker = songSeeker;

            if (Plugin.PlayingNewSong)
            {
                _prevStartTime = 0;
                _prevEndTime   = 1;
            }

            _lineDuration = new GameObject("Line Duration").AddComponent <Image>();
            var rectTransform = _lineDuration.rectTransform;

            rectTransform.SetParent(transform, false);
            rectTransform.anchorMin = Vector2.up * 0.5f;
            rectTransform.anchorMax = Vector2.up * 0.5f;
            rectTransform.sizeDelta = Vector2.zero;
            _lineDuration.color     = LineDurationColor;

            var startCursorImage = new GameObject("Start Cursor").AddComponent <Image>();

            rectTransform = startCursorImage.rectTransform;
            rectTransform.SetParent(transform, false);
            rectTransform.anchorMin        = Vector2.up * 0.5f;
            rectTransform.anchorMax        = Vector2.up * 0.5f;
            rectTransform.sizeDelta        = CursorSize;
            rectTransform.localEulerAngles = new Vector3(0, 0, 45);
            startCursorImage.color         = StartColor;

            _startCursor = startCursorImage.gameObject.AddComponent <LooperCursor>();
            _startCursor.BeginDragEvent += CursorOnBeginDragEvent;
            _startCursor.EndDragEvent   += CursorOnEndDragEvent;
            _startCursor.Position        = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _prevStartTime);

            var endCursorImage = new GameObject("End Cursor").AddComponent <Image>();

            rectTransform = endCursorImage.rectTransform;
            rectTransform.SetParent(transform, false);
            rectTransform.anchorMin        = Vector2.up * 0.5f;
            rectTransform.anchorMax        = Vector2.up * 0.5f;
            rectTransform.sizeDelta        = CursorSize;
            rectTransform.localEulerAngles = new Vector3(0, 0, 45);
            endCursorImage.color           = EndColor;

            _endCursor = endCursorImage.gameObject.AddComponent <LooperCursor>();
            _endCursor.BeginDragEvent += CursorOnBeginDragEvent;
            _endCursor.EndDragEvent   += CursorOnEndDragEvent;
            _endCursor.Position        = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _prevEndTime);

            _startCursor.Init(LooperCursor.Type.Start);
            _endCursor.Init(LooperCursor.Type.End);

            _mainCamera = Camera.main;
        }
Example #3
0
        public void Init(SongSeeker songSeeker)
        {
            _songSeeker = songSeeker;

            if (Plugin.PlayingNewSong)
            {
                _prevStartTime = 0;
                _prevEndTime   = 1;
            }

            var tex    = Texture2D.whiteTexture;
            var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.one * 0.5f, 100, 1);

            var bg            = new GameObject("Background").AddComponent <ImageView>();
            var rectTransform = bg.rectTransform;

            rectTransform.SetParent(transform, false);
            rectTransform.sizeDelta        = SongSeeker.SeekBarSize + new Vector2(0, 4);
            rectTransform.anchoredPosition = new Vector2(0, -1);
            bg.sprite   = sprite;
            bg.type     = Image.Type.Simple;
            bg.color    = new Color(0, 0, 0, 0);
            bg.material = Utilities.ImageResources.NoGlowMat;

            _lineDuration = new GameObject("Line Duration").AddComponent <ImageView>();
            rectTransform = _lineDuration.rectTransform;
            rectTransform.SetParent(transform, false);
            rectTransform.anchorMin = Vector2.up * 0.5f;
            rectTransform.anchorMax = Vector2.up * 0.5f;
            rectTransform.sizeDelta = Vector2.zero;
            _lineDuration.sprite    = sprite;
            _lineDuration.type      = Image.Type.Simple;
            _lineDuration.color     = LineDurationColor;
            _lineDuration.material  = Utilities.ImageResources.NoGlowMat;

            var startCursorImage = new GameObject("Start Cursor").AddComponent <ImageView>();

            rectTransform = startCursorImage.rectTransform;
            rectTransform.SetParent(transform, false);
            rectTransform.anchorMin        = Vector2.up * 0.5f;
            rectTransform.anchorMax        = Vector2.up * 0.5f;
            rectTransform.sizeDelta        = CursorSize;
            rectTransform.localEulerAngles = new Vector3(0, 0, 45);
            startCursorImage.sprite        = sprite;
            startCursorImage.type          = Image.Type.Simple;
            startCursorImage.color         = StartColor;
            startCursorImage.material      = Utilities.ImageResources.NoGlowMat;

            _startCursor = startCursorImage.gameObject.AddComponent <LooperCursor>();
            _startCursor.BeginDragEvent += CursorOnBeginDragEvent;
            _startCursor.EndDragEvent   += CursorOnEndDragEvent;
            _startCursor.Position        = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _prevStartTime);

            var endCursorImage = new GameObject("End Cursor").AddComponent <ImageView>();

            rectTransform = endCursorImage.rectTransform;
            rectTransform.SetParent(transform, false);
            rectTransform.anchorMin        = Vector2.up * 0.5f;
            rectTransform.anchorMax        = Vector2.up * 0.5f;
            rectTransform.sizeDelta        = CursorSize;
            rectTransform.localEulerAngles = new Vector3(0, 0, 45);
            endCursorImage.sprite          = sprite;
            endCursorImage.type            = Image.Type.Simple;
            endCursorImage.color           = EndColor;
            endCursorImage.material        = Utilities.ImageResources.NoGlowMat;

            _endCursor = endCursorImage.gameObject.AddComponent <LooperCursor>();
            _endCursor.BeginDragEvent += CursorOnBeginDragEvent;
            _endCursor.EndDragEvent   += CursorOnEndDragEvent;
            _endCursor.Position        = Mathf.Lerp(0, SongSeeker.SeekBarSize.x, _prevEndTime);

            _startCursor.Init(LooperCursor.Type.Start);
            _endCursor.Init(LooperCursor.Type.End);

            _mainCamera = Camera.main;
        }
Example #4
0
 private void CursorOnBeginDragEvent(LooperCursor cursor, PointerEventData eventData)
 {
     _draggingCursor = cursor;
 }