修复无子步骤时bug
This commit is contained in:
parent
fe5169e55a
commit
bf6b7c057a
@ -7,6 +7,7 @@ using TMPro;
|
||||
using System.Collections.Generic;
|
||||
using static OperationController;
|
||||
using System;
|
||||
using UnityEditor.Hardware;
|
||||
namespace QFramework.Example
|
||||
{
|
||||
public class UIOperationListData : UIPanelData
|
||||
@ -88,57 +89,62 @@ namespace QFramework.Example
|
||||
StepContent.RemoveAllChildren();
|
||||
foreach (var item in op.Steps)
|
||||
{
|
||||
GameObject obj = GameObject.Instantiate(Step.gameObject, StepContent);
|
||||
Transform title = obj.transform.Find("Title");
|
||||
var name = title.Find("Name").GetComponent<TextMeshProUGUI>();
|
||||
name.text = item.Name;
|
||||
var arrow = title.Find("Arrow").transform;
|
||||
Image highIcon = title.Find("HighIcon").GetComponent<Image>();
|
||||
Color highColor = new Color(25f / 255f, 224f / 255f, 224f / 255f);
|
||||
GameObject subContent = obj.transform.Find("SubContent").gameObject;
|
||||
Button btn = title.GetComponent<Button>();
|
||||
subContent.gameObject.SetActive(false);
|
||||
btn.name = btns.Count.ToString();
|
||||
btns.Add(btn);
|
||||
arrow.gameObject.SetActive(subContent.transform.childCount > 0);
|
||||
btn.onClick.AddListener(() =>
|
||||
|
||||
if (item.SubSteps != null && item.SubSteps.Count > 0)
|
||||
{
|
||||
if (subContent.transform.childCount > 0)
|
||||
GameObject obj = GameObject.Instantiate(Step.gameObject, StepContent);
|
||||
Transform title = obj.transform.Find("Title");
|
||||
var name = title.Find("Name").GetComponent<TextMeshProUGUI>();
|
||||
name.text = item.Name;
|
||||
var arrow = title.Find("Arrow").transform;
|
||||
Image highIcon = title.Find("HighIcon").GetComponent<Image>();
|
||||
Color highColor = new Color(25f / 255f, 224f / 255f, 224f / 255f);
|
||||
GameObject subContent = obj.transform.Find("SubContent").gameObject;
|
||||
Button btn = title.GetComponent<Button>();
|
||||
subContent.gameObject.SetActive(false);
|
||||
btn.name = btns.Count.ToString();
|
||||
btns.Add(btn);
|
||||
arrow.gameObject.SetActive(subContent.transform.childCount > 0);
|
||||
btn.onClick.AddListener(() =>
|
||||
{
|
||||
subContent.SetActive(!subContent.activeSelf);
|
||||
}
|
||||
if (op.freeStep)
|
||||
{
|
||||
if (highIcon.color != highColor)
|
||||
if (op.freeStep)
|
||||
{
|
||||
TypeEventSystem.Global.Send<StepExecute>(new StepExecute() { index = int.Parse(btn.name) });
|
||||
if (highIcon.color != highColor)
|
||||
{
|
||||
TypeEventSystem.Global.Send<StepExecute>(new StepExecute() { index = int.Parse(btn.name) });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (item.SubSteps != null)
|
||||
{
|
||||
});
|
||||
foreach (var sub in item.SubSteps)
|
||||
{
|
||||
GameObject subObj = GameObject.Instantiate(SubStep.gameObject, subContent.transform);
|
||||
var stepLabel = subObj.transform.Find("StepLabel").GetComponent<TextMeshProUGUI>();
|
||||
stepLabel.text = sub.Name;
|
||||
Button subBtn = subObj.GetComponent<Button>();
|
||||
subBtn.name = btns.Count.ToString();
|
||||
btns.Add(subBtn);
|
||||
subBtn.onClick.AddListener(() =>
|
||||
{
|
||||
if (op.freeStep)
|
||||
{
|
||||
subBtn.transform.parent.gameObject.SetActive(true);
|
||||
TypeEventSystem.Global.Send<StepExecute>(new StepExecute() { index = int.Parse(subBtn.name) });
|
||||
}
|
||||
});
|
||||
StepItemFactory(subContent.transform, sub.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StepItemFactory(StepContent, item.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void StepItemFactory(Transform content, string txt)
|
||||
{
|
||||
GameObject subObj = GameObject.Instantiate(SubStep.gameObject, content.transform);
|
||||
var stepLabel = subObj.transform.Find("StepLabel").GetComponent<TextMeshProUGUI>();
|
||||
stepLabel.text = txt;
|
||||
Button subBtn = subObj.GetComponent<Button>();
|
||||
subBtn.name = btns.Count.ToString();
|
||||
btns.Add(subBtn);
|
||||
subBtn.onClick.AddListener(() =>
|
||||
{
|
||||
if (op.freeStep)
|
||||
{
|
||||
subBtn.transform.parent.gameObject.SetActive(true);
|
||||
TypeEventSystem.Global.Send<StepExecute>(new StepExecute() { index = int.Parse(subBtn.name) });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user