Signed-off-by: TRAfoer <lhf190@outlook.com>
This commit is contained in:
@@ -2,18 +2,21 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni;
|
||||
using Ichni.RhythmGame;
|
||||
using Michsky.MUIP;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NotefabContoler : MonoBehaviour
|
||||
{
|
||||
public SampleWindow sampleWindow;
|
||||
public NoteBase noteBase;
|
||||
public RawImage ifHold;
|
||||
public void Initialize(NoteBase note, float timePerBeat, int beatDeviver)
|
||||
public void Initialize(NoteBase note, float timePerBeat, int beatDeviver, float posX)
|
||||
{
|
||||
noteBase = note;
|
||||
Image color = GetComponent<Image>();
|
||||
transform.localPosition = new Vector3(0, note.exactJudgeTime / timePerBeat * beatDeviver, 0);
|
||||
transform.localPosition = new Vector3(posX, note.exactJudgeTime / timePerBeat * beatDeviver, 0);
|
||||
switch (note)
|
||||
{
|
||||
case Hold hold:
|
||||
@@ -36,9 +39,42 @@ public class NotefabContoler : MonoBehaviour
|
||||
color.color = new Color(1, 0.2f, 0, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
public void Onclick()
|
||||
public void Update()
|
||||
{
|
||||
EditorManager.instance.uiManager.hierarchy.FindTab(noteBase);
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(this.GetComponent<RectTransform>(), Mouse.current.position.ReadValue()))
|
||||
{
|
||||
if (Mouse.current.leftButton.wasPressedThisFrame)
|
||||
{
|
||||
StartCoroutine(Moving());
|
||||
if (EditorManager.instance.uiManager.inspector.connectedGameElement != noteBase) EditorManager.instance.uiManager.hierarchy.FindTab(noteBase);
|
||||
}
|
||||
}
|
||||
}
|
||||
public IEnumerator Moving()
|
||||
{
|
||||
sampleWindow.GetComponent<WindowDragger>().Lock = true;
|
||||
float startX = transform.localPosition.x;
|
||||
while (Mouse.current.leftButton.isPressed)
|
||||
{
|
||||
Vector2 localMousePosition = GetComponent<RectTransform>().InverseTransformPoint(Mouse.current.position.ReadValue());
|
||||
// if (Mathf.Abs(localMousePosition.x - startX) > GetComponent<RectTransform>().sizeDelta.x / 2)
|
||||
{
|
||||
transform.localPosition += new Vector3(Mouse.current.delta.ReadValue().x, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
noteBase.noteVisual.transformSubmodule.originalPosition = new Vector3(
|
||||
transform.localPosition.x / sampleWindow.XWidth,
|
||||
noteBase.noteVisual.transformSubmodule.originalPosition.y,
|
||||
noteBase.noteVisual.transformSubmodule.originalPosition.z
|
||||
);
|
||||
noteBase.noteVisual.transformSubmodule.Refresh();
|
||||
|
||||
sampleWindow.GetComponent<WindowDragger>().Lock = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user