UIModelManager.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using SC.XR.Unity;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class UIModelManager : SingletonMono<UIModelManager>
  6. {
  7. public bool isinit = true;
  8. public string loadModelName = "";
  9. public GameObject ziYuanKuObj;
  10. public GameObject button;
  11. public Transform point;
  12. // Start is called before the first frame update
  13. void Start()
  14. {
  15. }
  16. // Update is called once per frame
  17. void Update()
  18. {
  19. if (API_GSXR_Slam.GSXR_Get_Head() != null && !ziYuanKuObj.activeSelf)
  20. {
  21. transform.position = new Vector3(point.position.x, 0, point.position.z);
  22. transform.eulerAngles = new Vector3(0, point.eulerAngles.y, 0);
  23. }
  24. }
  25. public void CreateModel( string modelName)
  26. {
  27. ZYKOnClick(false);
  28. string id = Random.Range(1000, 9999).ToString() + SynchronizeManager.Instance.modelNume++.ToString();
  29. Vector3 pos = API_GSXR_Slam.GSXR_Get_Head().forward * 2f + API_GSXR_Slam.GSXR_Get_Head().position;
  30. TransformData tranformData = new TransformData(pos, Vector3.zero, Vector3.one);
  31. ModelData data = new ModelData(id, modelName, tranformData, false, false, false);
  32. GameObject modelc = GameObject.Instantiate(Resources.Load<GameObject>("ModelC"));
  33. GameObject model = GameObject.Instantiate(Resources.Load<GameObject>(data.name));
  34. modelc.GetComponent<ModelC>().AddModel(model.transform);
  35. ModelSynchronize modelSync = modelc.GetComponent<ModelSynchronize>();
  36. modelSync.Init(data);
  37. SynchronizeManager.Instance.CreateModel(data);
  38. SynchronizeManager.Instance.AddModelSynchronize(modelSync);
  39. }
  40. public void CreateModel()
  41. {
  42. if (loadModelName != "")
  43. CreateModel(loadModelName);
  44. loadModelName = "";
  45. }
  46. public void DesModel( string ModelId )
  47. {
  48. SynchronizeManager.Instance.DesModel(ModelId);
  49. }
  50. public void ZYKOnClick( bool state )
  51. {
  52. ziYuanKuObj.SetActive(state);
  53. button.SetActive(!state);
  54. }
  55. }