2023-04-09 14:35:38 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class MousePreview : MonoBehaviour
|
|
|
|
{
|
|
|
|
// show mousePreviewObj in mouse position
|
2023-06-30 09:30:12 +00:00
|
|
|
public void ChangePreviewTo(GameObject mousePreviewObj)
|
2023-04-09 14:35:38 +00:00
|
|
|
{
|
2023-06-30 09:30:12 +00:00
|
|
|
DeleteAllPreviewModele();
|
2023-07-28 10:44:02 +00:00
|
|
|
Instantiate(mousePreviewObj, transform.position, Quaternion.identity, this.transform);
|
2023-04-09 14:35:38 +00:00
|
|
|
}
|
2023-07-28 10:44:02 +00:00
|
|
|
|
2023-06-30 09:30:12 +00:00
|
|
|
public void UpdatePreviewPosition(Vector3 previewPos)
|
2023-04-09 14:35:38 +00:00
|
|
|
{
|
|
|
|
// move this gameobject to previewPos
|
2023-07-28 10:44:02 +00:00
|
|
|
transform.position = previewPos;
|
2023-04-09 14:35:38 +00:00
|
|
|
}
|
2023-07-28 10:44:02 +00:00
|
|
|
|
2023-06-30 09:30:12 +00:00
|
|
|
public void DeleteAllPreviewModele()
|
2023-04-09 14:35:38 +00:00
|
|
|
{
|
|
|
|
// delete all child object
|
|
|
|
foreach (Transform childObj in this.transform)
|
|
|
|
{
|
|
|
|
// destroy child
|
|
|
|
Destroy(childObj.gameObject);
|
|
|
|
}
|
|
|
|
}
|
2023-07-28 10:44:02 +00:00
|
|
|
}
|