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;
///
/// 当前组合素材内所有单个素材
///
public List listMaterialValue;
void Start()
{
listMaterialValue = new List();
CreateMaterial();
}
///
/// 创建组合素材
///
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().dicCMVOjbes.Add(cMValue.name, new List());
//UIKit.GetPanel().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.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().dicObjs[spoitname].Add(materialShow.gameObject);
// UIKit.GetPanel().dicCMVOjbes[cMValue.name].Add(materialShow.gameObject);
}
///
/// 设置物体的初始位置
///
///
///
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;
}
}
}