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
47
|
using UnityEngine;
[AddComponentMenu("NGUI/Examples/Item Attachment Point")]
public class InvAttachmentPoint : MonoBehaviour
{
/// <summary>
/// Item slot that this attachment point covers.
/// </summary>
public InvBaseItem.Slot slot;
GameObject mPrefab;
GameObject mChild;
/// <summary>
/// Attach an instance of the specified game object.
/// </summary>
public GameObject Attach (GameObject prefab)
{
if (mPrefab != prefab)
{
mPrefab = prefab;
// Remove the previous child
if (mChild != null) Destroy(mChild);
// If we have something to create, let's do so now
if (mPrefab != null)
{
// Create a new instance of the game object
Transform t = transform;
mChild = Instantiate(mPrefab, t.position, t.rotation) as GameObject;
// Parent the child to this object
Transform ct = mChild.transform;
ct.parent = t;
// Reset the pos/rot/scale, just in case
ct.localPosition = Vector3.zero;
ct.localRotation = Quaternion.identity;
ct.localScale = Vector3.one;
}
}
return mChild;
}
}
|
Revision |
Author |
Commited |
Message |
83
|
FMMortaroli
|
Tue 13 May, 2014 11:32:51 +0000 |
|