Nextrek
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
//----------------------------------------------
// NGUI: Next-Gen UI kit
// Copyright © 2011-2013 Tasharen Entertainment
//----------------------------------------------
using UnityEngine;
[AddComponentMenu("NGUI/Examples/Drag and Drop Item (Example)")]
public class ExampleDragDropItem : UIDragDropItem
{
/// <summary>
/// Prefab object that will be instantiated on the DragDropSurface if it receives the OnDrop event.
/// </summary>
public GameObject prefab;
/// <summary>
/// Drop a 3D game object onto the surface.
/// </summary>
protected override void OnDragDropRelease (GameObject surface)
{
if (surface != null)
{
ExampleDragDropSurface dds = surface.GetComponent<ExampleDragDropSurface>();
if (dds != null)
{
GameObject child = NGUITools.AddChild(dds.gameObject, prefab);
Transform trans = child.transform;
trans.position = UICamera.lastHit.point;
if (dds.rotatePlacedObject)
{
trans.rotation = Quaternion.LookRotation(UICamera.lastHit.normal) * Quaternion.Euler(90f, 0f, 0f);
}
// Destroy this icon as it's no longer needed
NGUITools.Destroy(gameObject);
return;
}
}
base.OnDragDropRelease(surface);
}
}
|
Revision |
Author |
Commited |
Message |
83
|
FMMortaroli
|
Tue 13 May, 2014 11:32:51 +0000 |
|