using System; using UnityEngine; [AddComponentMenu("NGUI/Examples/Drag and Drop Item (Example)")] public class ExampleDragDropItem : UIDragDropItem { protected override void OnDragDropRelease(GameObject surface) { if (surface != null) { ExampleDragDropSurface component = surface.GetComponent(); if (component != null) { GameObject gameObject = NGUITools.AddChild(component.gameObject, this.prefab); gameObject.transform.localScale = component.transform.localScale; Transform transform = gameObject.transform; transform.position = UICamera.lastWorldPosition; if (component.rotatePlacedObject) { transform.rotation = Quaternion.LookRotation(UICamera.lastHit.normal) * Quaternion.Euler(90f, 0f, 0f); } NGUITools.Destroy(base.gameObject); return; } } base.OnDragDropRelease(surface); } public GameObject prefab; }