CreateModel.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using SC.XR.Unity.Module_InputSystem;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.EventSystems;
  6. using XRTool.Util;
  7. public class CreateModel : MonoBehaviour, IPointerUpHandler, IPointerDownHandler, IPointerClickHandler
  8. {
  9. // Start is called before the first frame update
  10. void Start()
  11. {
  12. }
  13. // Update is called once per frame
  14. void Update()
  15. {
  16. }
  17. private GameObject model;
  18. public void OnPointerUp(PointerEventData eventData)
  19. {
  20. }
  21. public void OnPointerDown(PointerEventData eventData)
  22. {
  23. }
  24. public void OnPointerClick(PointerEventData eventData)
  25. {
  26. model = GameObject.Instantiate(this.gameObject);
  27. model.GetComponent<CreateModel>().enabled = false;
  28. model.GetComponent<XBoundingBox>().enabled = false;
  29. model.GetComponent<XDragComponent>().enabled = false;
  30. model.GetComponent<CreateModel>().enabled = false;
  31. Debug.Log("创建物体");
  32. model.transform.localScale = new Vector3(0, 0, 0);
  33. model.AddComponent<ModelManager>();
  34. model.transform.parent = GSXRManager.Instance.head;
  35. }
  36. }