InvAttachmentPoint.cs 878 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using UnityEngine;
  3. [AddComponentMenu("NGUI/Examples/Item Attachment Point")]
  4. public class InvAttachmentPoint : MonoBehaviour
  5. {
  6. public GameObject Attach(GameObject prefab)
  7. {
  8. if (this.mPrefab != prefab)
  9. {
  10. this.mPrefab = prefab;
  11. if (this.mChild != null)
  12. {
  13. UnityEngine.Object.Destroy(this.mChild);
  14. }
  15. if (this.mPrefab != null)
  16. {
  17. Transform transform = base.transform;
  18. this.mChild = UnityEngine.Object.Instantiate<GameObject>(this.mPrefab, transform.position, transform.rotation);
  19. Transform transform2 = this.mChild.transform;
  20. transform2.parent = transform;
  21. transform2.localPosition = Vector3.zero;
  22. transform2.localRotation = Quaternion.identity;
  23. transform2.localScale = Vector3.one;
  24. }
  25. }
  26. return this.mChild;
  27. }
  28. public InvBaseItem.Slot slot;
  29. private GameObject mPrefab;
  30. private GameObject mChild;
  31. }