1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- /****************************************************************************
- * 2022.1 SK-20211220VCWK
- ****************************************************************************/
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using QFramework;
- using UniRx;
- namespace QFramework.MREditor
- {
- public partial class UISpoits : UIElement
- {
- private void Awake()
- {
- }
- protected override void OnBeforeDestroy()
- {
- }
- private ToggleGroup group;
- private List<SpoitBtn> listbtns;
- private UIMaterials uIMaterials1;
- public void Initialized(List<SpoitValue> listSpoits ,SpoitBtn spoitBtn ,MaterialBtn materialBtn , UIMaterials uIMaterials)
- {
- listbtns = new List<SpoitBtn>();
- this.uIMaterials1 = uIMaterials;
- group = UISpoitContent.GetComponent<ToggleGroup>();
- listSpoits.ForEach(item =>
- {
-
- spoitBtn.Instantiate()
- .Parent(UISpoitContent)
- .Identity()
- .ApplySelfTo(btn =>
- {
- Toggle toggle = btn.GetComponent<Toggle>();
- toggle.onValueChanged.AddListener(state =>
- {
- if (state)
- {
- SendMsg(new OnSelectObjName(item.name,item.name, item.name));
- uIMaterials.SelectSpoit(item.name);
- }
- });
- toggle.group = group;
- btn.Text.text = item.name;
- listbtns.Add(btn);
- })
- .Show();
-
- Debug.Log("$$$ " + item.name);
- spoitBtn.Identity();
-
- uIMaterials.Initialized(item.name, item.material, materialBtn);
- });
- uIMaterials.InitBtn();
- BtnInit();
- }
- public void BtnInit()
- {
- Debug.Log("BtnInit");
- listbtns.ForEach(item =>
- {
- Vector3 pos = item.GetComponent<RectTransform>().anchoredPosition3D;
- item.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(pos.x, pos.y, 0);
- });
- }
- public void SelectSpoitObj(string name)
- {
- uIMaterials1.SelectSpoit(name);
- }
- }
- }
|