60 lines
1.5 KiB
C#
60 lines
1.5 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.Splines;
|
|
|
|
public class SplineTarget : MonoBehaviour
|
|
{
|
|
public BezierKnot knot;
|
|
public event Action<BezierKnot, int, int> onKnotChanged;
|
|
public event Action onChangeFinished;
|
|
bool isClick;
|
|
public int index;
|
|
public int splineIndex;
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
/*
|
|
if (isClick)
|
|
{
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
RaycastHit hit;
|
|
if (Physics.Raycast(ray, out hit))
|
|
{
|
|
transform.position = hit.point + new Vector3(0, 2, 0);
|
|
knot.Position = transform.position - new Vector3(0, 2, 0);
|
|
onKnotChanged?.Invoke(knot, index, splineIndex);
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
|
|
public void Init(BezierKnot knot, int index, int splineIndex = 0)
|
|
{
|
|
this.knot = knot;
|
|
this.index = index;
|
|
this.splineIndex = splineIndex;
|
|
}
|
|
|
|
/*
|
|
public void OnPointerDown(PointerEventData eventData)
|
|
{
|
|
isClick = true;
|
|
transform.GetComponent<Collider>().enabled = false;
|
|
}
|
|
|
|
public void OnPointerUp(PointerEventData eventData)
|
|
{
|
|
isClick = false;
|
|
transform.GetComponent<Collider>().enabled = true;
|
|
onChangeFinished?.Invoke();
|
|
}
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
Debug.Log("click");
|
|
}
|
|
*/
|
|
}
|