using System.Collections; using System.Collections.Generic; using System.Xml.Serialization; using UnityEngine; public class MousePreview : MonoBehaviour { // show mousePreviewObj in mouse position public void ChangePreviewTo(GameObject mousePreviewObj) { DeleteAllPreviewModele(); Instantiate(mousePreviewObj, this.transform.position, Quaternion.identity, this.transform); } public void UpdatePreviewPosition(Vector3 previewPos) { // move this gameobject to previewPos this.transform.position = previewPos; } public void DeleteAllPreviewModele() { // delete all child object foreach (Transform childObj in this.transform) { // destroy child Destroy(childObj.gameObject); } } }