123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- /****************************************************************************
- * 2022.1 SK-20211220VCWK
- ****************************************************************************/
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using QFramework;
- namespace QFramework.MREditor
- {
- public partial class UIEditor : UIElement
- {
- private void Awake()
- {
- }
- protected override void OnBeforeDestroy()
- {
- }
- public void Close()
- {
- gameObject.SetActive(false);
- }
- private Transform MaterialObj;
- private List<ObjectTData> listAlter;
- private List<SpoitValue> listSpoits;
- public void Initialized(List<SpoitValue> listSpoits)
- {
- MaterialObj = null;
- this.listSpoits = listSpoits;
- listAlter = new List<ObjectTData>();
- #region BtnInitialized
- UCBtn.onClick.AddListener(() =>
- {
- if (UCElenemt.gameObject.activeSelf)
- return;
- UCElenemt.gameObject.SetActive(true);
- TicElenemt.gameObject.SetActive(false);
- });
- TicBtn.onClick.AddListener(() =>
- {
- if (TicElenemt.gameObject.activeSelf)
- return;
- UCElenemt.gameObject.SetActive(false);
- TicElenemt.gameObject.SetActive(true);
- });
- RemoveBtn.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SendMsg(new OnRemoveDataSetting("SelectObj"));
- // 痄壺絞ゴ匼第
- });
-
- // RemoveBtn.gameObject.SetActive(false);
- AddSize.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localScale += new Vector3(MaterialObj.localScale.x / 10.0f, MaterialObj.localScale.y / 10.0f, MaterialObj.localScale.z / 10.0f);
- });
- SubSize.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localScale -= new Vector3(MaterialObj.localScale.x / 10.0f, MaterialObj.localScale.y / 10.0f, MaterialObj.localScale.z / 10.0f);
- });
- AddRot.GetComponent<SCButton>().onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localEulerAngles += new Vector3(0, 10, 0);
- });
- SubRot.GetComponent<SCButton>().onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localEulerAngles -= new Vector3(0, 10, 0);
- });
- // SubRot.onClick.AddListener(() =>
- // {
- // if (MaterialObj == null)
- // return;
- // SaveAlter();
- // MaterialObj.localEulerAngles -= new Vector3(0, 10, 0);
- //});
- AddX.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localPosition -= new Vector3(0.1f, 0, 0);
- });
- SubX.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localPosition += new Vector3(0.1f, 0, 0);
- });
- AddY.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localPosition += new Vector3(0, 0.1f, 0);
- });
- SubY.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localPosition -= new Vector3(0, 0.1f, 0);
- });
- ADDXBtn.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localPosition -= new Vector3(0.1f, 0, 0);
- });
- SubXBtn.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localPosition += new Vector3(0.1f, 0, 0);
- });
- ADDYBtn.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localPosition += new Vector3(0, 0.1f, 0);
- });
- SubYBtn.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localPosition -= new Vector3(0, 0.1f, 0);
- });
- AddZBtn.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localPosition += new Vector3(0, 0, 0.1f);
- });
- SubZBtn.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SaveAlter();
- MaterialObj.localPosition -= new Vector3(0, 0, 0.1f);
- });
- InitiativeBtn.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- InitMaterialObj();
- });
- RevocationBtn.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- MaterialObj.localPosition = listAlter[listAlter.Count - 1].pos;
- MaterialObj.localEulerAngles = listAlter[listAlter.Count - 1].rot;
- MaterialObj.localScale = listAlter[listAlter.Count - 1].scale;
- listAlter.RemoveAt(listAlter.Count - 1);
- });
- SaveBtn.onClick.AddListener(() =>
- {
- if (MaterialObj == null)
- return;
- SendMsg(new OnSaveDataSetting(MaterialObj.name, MaterialObj.localPosition, MaterialObj.localEulerAngles, MaterialObj.localScale));
- });
- #endregion
- }
- /// <summary>
- /// 恁寁匼第
- /// </summary>
- /// <param name="MaterialObj"></param>
- public void SelectMaterial(Transform MaterialObj)
- {
- this.MaterialObj = MaterialObj;
- listAlter.Clear();
- listAlter = new List<ObjectTData>();
- }
- private void InitMaterialObj()
- {
- if (MaterialObj == null)
- return;
- string name = MaterialObj.name;
- listAlter.Clear();
- listAlter = new List<ObjectTData>();
- for (int i = 0; i < listSpoits.Count; i++)
- {
- if(listSpoits[i].name == name)
- {
-
- }
- }
- //脤梑劓萸睿劓萸囀腔郪磁匼第靡
- List<CompositeMaterialValue> listCMV = new List<CompositeMaterialValue>();
- for (int i = 0; i < listSpoits.Count; i++)
- {
- if(listSpoits[i].name ==name)
- {
- SetObjTransform(MaterialObj, listSpoits[i].spoitTf);
- return;
- }
- for (int j = 0; j < listSpoits[i].material.Count; j++)
- {
- switch ((MaterialType)listSpoits[i].material[j].type)
- {
- case MaterialType.NULL:
- break;
- case MaterialType.Image:
- break;
- case MaterialType.Video:
- break;
- case MaterialType.Model:
- break;
- case MaterialType.Text:
- break;
- case MaterialType.ImageorViedoAndText:
- if (listSpoits[i].material[j].name == name)
- {
- SetObjTransform(MaterialObj, listSpoits[i].material[j].objectTransform);
- return;
- }
-
- break;
- case MaterialType.ModelAndText:
- if (listSpoits[i].material[j].name == name)
- {
- SetObjTransform(MaterialObj, listSpoits[i].material[j].objectTransform);
- return;
- }
-
- break;
- default:
- break;
- }
- listCMV.Add(listSpoits[i].material[j]);
- }
- }
- //脤梑郪磁匼第囀等跺匼第
- for (int i = 0; i < listCMV.Count; i++)
- {
- for (int j = 0; j < listCMV[i].materialList.Count; j++)
- {
- if (listCMV[i].materialList[j].name == name)
- {
- SetObjTransform(MaterialObj, listCMV[i].materialList[j].ObjectTransform);
- return;
- }
- }
- }
- }
- private void SetObjTransform(Transform obj , ObjectTransform objTransform )
- {
- obj.localPosition = objTransform.startPos;
- obj.localEulerAngles = objTransform.startRot;
- obj.localScale = objTransform.startScale;
- }
- private void SaveAlter()
- {
- ObjectTData data = new ObjectTData();
- data.pos = MaterialObj.localPosition;
- data.rot = MaterialObj.localEulerAngles;
- data.scale = MaterialObj.localScale;
- listAlter.Add(data);
- }
- }
- }
|