1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using SC.XR.Unity;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class UIModelManager : SingletonMono<UIModelManager>
- {
- public bool isinit = true;
- public string loadModelName = "";
- public List<ZiYuanFileItem> listItem;
- public GameObject ziYuanKuObj;
- public GameObject button;
- public Transform point;
-
- // Start is called before the first frame update
- void Start()
- {
-
- }
- // Update is called once per frame
- void Update()
- {
- if (OpenXRCamera.Instance.head != null && !ziYuanKuObj.activeSelf)
- {
-
- transform.position = new Vector3(point.position.x, 1.5f, point.position.z);
- transform.eulerAngles = new Vector3(0, point.eulerAngles.y, 0);
- }
- }
- public void CreateModel( string modelName)
- {
- ZYKOnClick(false);
- string id = Random.Range(1000, 9999).ToString() + SynchronizeManager.Instance.modelNume++.ToString();
- Vector3 pos = OpenXRCamera.Instance.head.forward * 2f + OpenXRCamera.Instance.head.position;
- TransformData tranformData = new TransformData(pos, Vector3.zero, Vector3.one);
- ModelData data = new ModelData(id, modelName, tranformData, false, false, false);
- GameObject modelc = GameObject.Instantiate(Resources.Load<GameObject>("ModelC"));
- GameObject model = GameObject.Instantiate(Resources.Load<GameObject>(data.name));
- modelc.GetComponent<ModelC>().AddModel(model.transform);
- ModelSynchronize modelSync = modelc.GetComponent<ModelSynchronize>();
- modelSync.Init(data);
- SynchronizeManager.Instance.CreateModel(data);
- SynchronizeManager.Instance.AddModelSynchronize(modelSync);
- }
- public void CreateModel()
- {
- for (int i = 0; i < listItem.Count; i++)
- {
- listItem[i].blueImage.SetActive(false);
- }
- if (loadModelName != "")
- CreateModel(loadModelName);
- loadModelName = "";
- }
- public void DesModel( string ModelId )
- {
- SynchronizeManager.Instance.DesModel(ModelId);
- }
- public void ZYKOnClick( bool state )
- {
- ziYuanKuObj.SetActive(state);
- button.SetActive(!state);
- }
- }
|