123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using QFramework;
- using UniRx;
- using QFramework.MREditor;
- public class CMaterialValueShow : MonoBehaviour
- {
- public CompositeMaterialValue cMValue;
- public string spoitname;
- /// <summary>
- /// 当前组合素材内所有单个素材
- /// </summary>
- public List<MaterialShow> listMaterialValue;
- void Start()
- {
- listMaterialValue = new List<MaterialShow>();
- CreateMaterial();
-
- }
- /// <summary>
- /// 创建组合素材
- /// </summary>
- private void CreateMaterial()
- {
- switch ((MaterialType)cMValue.type)
- {
- case MaterialType.NULL:
- break;
- case MaterialType.Image:
-
- case MaterialType.Video:
-
- case MaterialType.Model:
-
- case MaterialType.Text:
-
- case MaterialType.ImageorViedoAndText:
-
- case MaterialType.ModelAndText:
- //UIKit.GetPanel<EditorPanel>().dicCMVOjbes.Add(cMValue.name, new List<GameObject>());
- //UIKit.GetPanel<EditorPanel>().dicCMVOjbes[cMValue.name].Add(gameObject);
- cMValue.materialList.ForEach(item =>
- {
- StartCoroutine(LoadMaterialObj(item));
-
- });
- break;
- default:
- break;
- }
- }
- private IEnumerator LoadMaterialObj(MaterialObjValue item)
- {
- GameObject obj = new GameObject(item.name);
- yield return new WaitForFixedUpdate();
- obj.transform.parent = transform;
- obj.transform.LocalIdentity();
- // SetObjMaterial(obj, item.ObjectTransform);
- Debug.Log(obj.name + " " + item.ObjectTransform);
- MaterialShow materialShow = obj.AddComponent<MaterialShow>();
- materialShow.value = item;
- materialShow.spoitName = spoitname;
- Debug.Log(item.name + " " + item.ObjectTransform.startPos.x);
- materialShow.type = cMValue.template;
- materialShow.updateTime = cMValue.updateTime;
- listMaterialValue.Add(materialShow);
- Debug.Log(item.name);
- UIKit.GetPanel<EditorPanel>().dicObjs[spoitname].Add(materialShow.gameObject);
- // UIKit.GetPanel<EditorPanel>().dicCMVOjbes[cMValue.name].Add(materialShow.gameObject);
- }
- /// <summary>
- /// 设置物体的初始位置
- /// </summary>
- /// <param name="obj"></param>
- /// <param name="objectData"></param>
- public void SetObjMaterial(GameObject obj, ObjectTransform objectData)
- {
- Debug.Log(objectData.startScale);
- if (objectData == null)
- return;
- if (objectData.nowScale == Vector3.zero)
- {
- obj.transform.localPosition = objectData.startPos;
- obj.transform.localEulerAngles = objectData.startRot;
- obj.transform.localScale = objectData.startScale;
- }
- else
- {
- obj.transform.localPosition = objectData.nowPos;
- obj.transform.localEulerAngles = objectData.nowRot;
- obj.transform.localScale = objectData.nowScale;
- }
- }
- }
|