642 lines
23 KiB
C#
642 lines
23 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using TMPro;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
using YiLiao.JingLuoXueWei;
|
|
|
|
using ZXKFramework;
|
|
|
|
public enum colo
|
|
{
|
|
white,
|
|
gray
|
|
}
|
|
public class LeftBigBtnPanel : UIBase
|
|
{
|
|
/// <summary>
|
|
/// 所有经络按钮
|
|
/// </summary>
|
|
List<Button> allBigBtn = new List<Button>();
|
|
List<Button> allSmallBtn = new List<Button>();
|
|
|
|
/// <summary>
|
|
/// 所有经络按钮以及相对应的子按钮父物体
|
|
/// </summary>
|
|
Dictionary<Button, GameObject> JingLuoXueWeiDict = new Dictionary<Button, GameObject>();
|
|
|
|
/// <summary>
|
|
/// 已经创建子按钮的经络
|
|
/// </summary>
|
|
List<string> isCreateBtnLst = new List<string>();
|
|
|
|
/// <summary>
|
|
/// 已经创建说明文本的经络
|
|
/// </summary>
|
|
List<string> isCreateTxtLst = new List<string>();
|
|
|
|
/// <summary>
|
|
/// 创建的所有穴位文本(用于变色)
|
|
/// </summary>
|
|
List<GameObject> allXueWei_Txt = new List<GameObject>();
|
|
public override string GroupName => typeof(LeftBigBtnPanel).Name;
|
|
|
|
public override string Name => typeof(LeftBigBtnPanel).Name;
|
|
|
|
GameManager gameManager;
|
|
|
|
GameModel gameModel;
|
|
|
|
Button xunXing_Btn;
|
|
/// <summary>
|
|
/// 是否开启循行
|
|
/// </summary>
|
|
bool isOpenXunXing = false;
|
|
|
|
/// <summary>
|
|
/// 当前选择的经络
|
|
/// </summary>
|
|
string selectJingLuoName = "";
|
|
|
|
/// <summary>
|
|
/// 控制是否透明按钮
|
|
/// </summary>
|
|
Button touMing_Btn;
|
|
|
|
/// <summary>
|
|
/// 是否透明
|
|
/// </summary>
|
|
bool isTouMing = false;
|
|
|
|
Button fuWei_Btn;
|
|
|
|
/// <summary>
|
|
/// 人物的旋转
|
|
/// </summary>
|
|
float startRotY = 180f;
|
|
/// <summary>
|
|
/// 搜索按钮
|
|
/// </summary>
|
|
Button souSuo_Btn;
|
|
Coroutine cor;
|
|
GameObject model_Body;
|
|
Vector3 startPos;
|
|
Vector3 startRot;
|
|
/// <summary>
|
|
/// 返回首页按钮
|
|
/// </summary>
|
|
Button home_Btn;
|
|
|
|
/// <summary>
|
|
/// 退出关闭按钮
|
|
/// </summary>
|
|
Button shutDown_Btn;
|
|
|
|
/// <summary>
|
|
/// 切换背景颜色
|
|
/// </summary>
|
|
Button qieHuan_Btn;
|
|
|
|
Button qingChu_Btn;
|
|
colo co = colo.white;
|
|
public override void Init(IUIManager uictrl)
|
|
{
|
|
base.Init(uictrl);
|
|
gameManager = GameManager.Instance;
|
|
gameModel = MVC.GetModel<GameModel>();
|
|
xunXing_Btn = transform.FindFirst<Button>("xunXing_Btn");
|
|
touMing_Btn = transform.FindFirst<Button>("touMing_Btn");
|
|
fuWei_Btn = transform.FindFirst<Button>("fuWei_Btn");
|
|
souSuo_Btn = transform.FindFirst<Button>("souSuo_Btn");
|
|
model_Body = gameManager.transform.parent.FindFirst("SM_body").gameObject;
|
|
startPos = model_Body.transform.localPosition;
|
|
startRot = model_Body.transform.localEulerAngles;
|
|
home_Btn = transform.FindFirst<Button>("Home");
|
|
shutDown_Btn = transform.FindFirst<Button>("ShutDown");
|
|
qieHuan_Btn = transform.FindFirst<Button>("qieHuan_Btn");
|
|
qingChu_Btn = transform.FindFirst<Button>("qingChu_Btn");
|
|
|
|
qieHuan_Btn.onClick.AddListener(() =>
|
|
{
|
|
if (co.Equals(colo.white))
|
|
{
|
|
transform.FindFirst<Image>("Bg").color = new Color(.8f, .8f, .8f, 1);
|
|
co = colo.gray;
|
|
return;
|
|
}
|
|
if (co.Equals(colo.gray))
|
|
{
|
|
transform.FindFirst<Image>("Bg").color = new Color(1f, 1f, 1f, 1f);
|
|
co = colo.white;
|
|
return;
|
|
}
|
|
});
|
|
qingChu_Btn.onClick.AddListener(() =>
|
|
{
|
|
ClearDrawLine();
|
|
});
|
|
#region 大按钮和子按钮到字典
|
|
Button FeiJing = transform.FindFirst<Button>("肺经");
|
|
GameObject feiJingChild = transform.FindFirst("肺经子按钮");
|
|
allBigBtn.Add(FeiJing);
|
|
JingLuoXueWeiDict.Add(FeiJing, feiJingChild);
|
|
|
|
Button DaChang = transform.FindFirst<Button>("大肠");
|
|
GameObject daChangChild = transform.FindFirst("大肠子按钮");
|
|
allBigBtn.Add(DaChang);
|
|
JingLuoXueWeiDict.Add(DaChang, daChangChild);
|
|
|
|
Button WeiJing = transform.FindFirst<Button>("胃经");
|
|
GameObject weiJingChild = transform.FindFirst("胃经子按钮");
|
|
allBigBtn.Add(WeiJing);
|
|
JingLuoXueWeiDict.Add(WeiJing, weiJingChild);
|
|
|
|
Button PiJing = transform.FindFirst<Button>("脾经");
|
|
GameObject piJingChild = transform.FindFirst("脾经子按钮");
|
|
allBigBtn.Add(PiJing);
|
|
JingLuoXueWeiDict.Add(PiJing, piJingChild);
|
|
|
|
Button XinJing = transform.FindFirst<Button>("心经");
|
|
GameObject xinJingChild = transform.FindFirst("心经子按钮");
|
|
allBigBtn.Add(XinJing);
|
|
JingLuoXueWeiDict.Add(XinJing, xinJingChild);
|
|
|
|
Button XiaoChang = transform.FindFirst<Button>("小肠");
|
|
GameObject xiaoChangChild = transform.FindFirst("小肠子按钮");
|
|
allBigBtn.Add(XiaoChang);
|
|
JingLuoXueWeiDict.Add(XiaoChang, xiaoChangChild);
|
|
|
|
Button PangGuang = transform.FindFirst<Button>("膀胱");
|
|
GameObject pangGuangChild = transform.FindFirst("膀胱子按钮");
|
|
allBigBtn.Add(PangGuang);
|
|
JingLuoXueWeiDict.Add(PangGuang, pangGuangChild);
|
|
|
|
Button ShenJing = transform.FindFirst<Button>("肾经");
|
|
GameObject shenJingChild = transform.FindFirst("肾经子按钮");
|
|
allBigBtn.Add(ShenJing);
|
|
JingLuoXueWeiDict.Add(ShenJing, shenJingChild);
|
|
|
|
Button XinBao = transform.FindFirst<Button>("心包");
|
|
GameObject xinBaoChild = transform.FindFirst("心包子按钮");
|
|
allBigBtn.Add(XinBao);
|
|
JingLuoXueWeiDict.Add(XinBao, xinBaoChild);
|
|
|
|
Button SanJiao = transform.FindFirst<Button>("三焦");
|
|
GameObject sanJiaoChild = transform.FindFirst("三焦子按钮");
|
|
allBigBtn.Add(SanJiao);
|
|
JingLuoXueWeiDict.Add(SanJiao, sanJiaoChild);
|
|
|
|
Button DanJing = transform.FindFirst<Button>("胆经");
|
|
GameObject danJingChild = transform.FindFirst("胆经子按钮");
|
|
allBigBtn.Add(DanJing);
|
|
JingLuoXueWeiDict.Add(DanJing, danJingChild);
|
|
|
|
Button GanJing = transform.FindFirst<Button>("肝经");
|
|
GameObject ganJingChild = transform.FindFirst("肝经子按钮");
|
|
allBigBtn.Add(GanJing);
|
|
JingLuoXueWeiDict.Add(GanJing, ganJingChild);
|
|
|
|
Button RenMai = transform.FindFirst<Button>("任脉");
|
|
GameObject renMaiChild = transform.FindFirst("任脉子按钮");
|
|
allBigBtn.Add(RenMai);
|
|
JingLuoXueWeiDict.Add(RenMai, renMaiChild);
|
|
|
|
Button DuMai = transform.FindFirst<Button>("督脉");
|
|
GameObject duMaiChild = transform.FindFirst("督脉子按钮");
|
|
allBigBtn.Add(DuMai);
|
|
JingLuoXueWeiDict.Add(DuMai, duMaiChild);
|
|
|
|
Button QiXue = transform.FindFirst<Button>("奇穴");
|
|
GameObject qiXueChild = transform.FindFirst("奇穴子按钮");
|
|
allBigBtn.Add(QiXue);
|
|
JingLuoXueWeiDict.Add(QiXue, qiXueChild);
|
|
#endregion
|
|
|
|
foreach (var item in JingLuoXueWeiDict)
|
|
{
|
|
item.Value.SetActive(true);
|
|
}
|
|
for (int i = 0; i < allBigBtn.Count; i++)
|
|
{
|
|
CreateBtnAsName(allBigBtn[i]);
|
|
JingLuoXueWeiDict[allBigBtn[i]].SetActive(false);
|
|
}
|
|
|
|
//循行按钮点击事件
|
|
xunXing_Btn.onClick.AddListener(XunXingClick);
|
|
//透明按钮点击事件
|
|
touMing_Btn.onClick.AddListener(TouMingClick);
|
|
//旋转按钮点击事件
|
|
fuWei_Btn.onClick.AddListener(FuWeiClick);
|
|
souSuo_Btn.onClick.AddListener(() =>
|
|
{
|
|
uiManager.ShowUI<SouSuoPanel>();
|
|
});
|
|
|
|
for (int i = 0; i < allBigBtn.Count; i++)
|
|
{
|
|
int id = i;
|
|
allBigBtn[i].onClick.AddListener(() =>
|
|
{
|
|
selectJingLuoName = allBigBtn[id].GetComponentInChildren<TMP_Text>().text;
|
|
//this.Log(id);
|
|
BtnAddListener(allBigBtn[id]);
|
|
|
|
//开启循行
|
|
isOpenXunXing = true;
|
|
xunXing_Btn.GetComponent<BtnImage>().OnEnterBtn();
|
|
gameManager.ChangeJingLuoDefaultColor();
|
|
gameManager.ChangeJingLuoColor(selectJingLuoName);
|
|
});
|
|
}
|
|
|
|
home_Btn.onClick.AddListener(() =>
|
|
{
|
|
Game.Instance.sound.StopBGM();
|
|
Game.Instance.IEnumeratorManager.StopAll();
|
|
UnityEngine.SceneManagement.SceneManager.LoadScene("Main");
|
|
});
|
|
|
|
shutDown_Btn.onClick.AddListener(() =>
|
|
{
|
|
#if UNITY_EDITOR
|
|
//在编辑器模式下
|
|
EditorApplication.isPlaying = false;
|
|
#else
|
|
Application.Quit();
|
|
#endif
|
|
});
|
|
}
|
|
|
|
public void ClearDrawLine()
|
|
{
|
|
GameObject[] allObjects = Resources.FindObjectsOfTypeAll<GameObject>();
|
|
var targetObjects = allObjects.Where(obj => obj.name.Contains("MarkerLineHolder")).ToList();
|
|
foreach (var obj in targetObjects)
|
|
{
|
|
if (obj != null)
|
|
{
|
|
Destroy(obj);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void FuWeiClick()
|
|
{
|
|
#region 之前的旋转逻辑 已改为复位逻辑
|
|
//startRotY += 45f;
|
|
//if (startRotY > 360f)
|
|
//{
|
|
// startRotY = 45f;
|
|
//}
|
|
//if (startRotY < 0f)
|
|
//{
|
|
// startRotY = 315f;
|
|
//}
|
|
//gameManager.transform.parent.FindFirst("SM_body").transform.localEulerAngles = new Vector3(0f, startRotY, 0f);
|
|
#endregion
|
|
model_Body.transform.localPosition = startPos;
|
|
model_Body.transform.localEulerAngles = startRot;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 循行按钮的点击事件
|
|
/// </summary>
|
|
public void XunXingClick()
|
|
{
|
|
isOpenXunXing = !isOpenXunXing;
|
|
if (!string.IsNullOrEmpty(selectJingLuoName))
|
|
{
|
|
if (isOpenXunXing)
|
|
{
|
|
xunXing_Btn.GetComponent<BtnImage>().OnEnterBtn();
|
|
gameManager.ChangeJingLuoDefaultColor();
|
|
gameManager.ChangeJingLuoColor(selectJingLuoName);
|
|
}
|
|
else
|
|
{
|
|
gameManager.ChangeJingLuoDefaultColor();
|
|
xunXing_Btn.GetComponent<BtnImage>().OnExitBtn();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 透明按钮事件
|
|
/// </summary>
|
|
public void TouMingClick()
|
|
{
|
|
isTouMing = !isTouMing;
|
|
if (isTouMing)
|
|
{
|
|
touMing_Btn.GetComponent<BtnImage>().OnEnterBtn();
|
|
//TODO 透明身体
|
|
gameManager.transform.parent.FindFirst<Renderer>("b_r3").material = gameManager.touMingMaterial;
|
|
gameManager.transform.parent.FindFirst<Renderer>("b_l3").material = gameManager.touMingMaterial;
|
|
gameManager.transform.parent.FindFirst("body15").SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
touMing_Btn.GetComponent<BtnImage>().OnExitBtn();
|
|
//TODO 取消透明身体
|
|
gameManager.transform.parent.FindFirst<Renderer>("b_r3").material = gameManager.noTouMingMaterial;
|
|
gameManager.transform.parent.FindFirst<Renderer>("b_l3").material = gameManager.noTouMingMaterial;
|
|
gameManager.transform.parent.FindFirst("body15").SetActive(true);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 经络按钮点击事件
|
|
/// </summary>
|
|
/// <param name="btn"></param>
|
|
void BtnAddListener(Button btn)
|
|
{
|
|
for (int i = 0; i < allBigBtn.Count; i++)
|
|
{
|
|
allBigBtn[i].GetComponent<BtnImage>().isOpen = false;
|
|
}
|
|
if (!btn.GetComponent<BtnImage>().isOpen)//当前按钮处于选中状态
|
|
{
|
|
for (int j = 0; j < allBigBtn.Count; j++)
|
|
{
|
|
if (allBigBtn[j].Equals(btn))
|
|
{
|
|
gameManager.selectJingLuoName = allBigBtn[j].GetComponentInChildren<TMP_Text>().text;
|
|
///切换选中按钮的背景
|
|
allBigBtn[j].GetComponent<BtnImage>().OnEnterBtn();
|
|
btn.GetComponent<BtnImage>().isOpen = true;
|
|
//显示经络
|
|
string nam = gameModel.excelData.GetJingLuoBigname(allBigBtn[j].GetComponentInChildren<TMP_Text>().text).activeGame;
|
|
ActiveSelectJingLuo(nam);
|
|
|
|
//播放经络音频
|
|
Game.Instance.sound.StopBGM();
|
|
Game.Instance.sound.PlayBGM(gameModel.excelData.GetJingLuoBigname(allBigBtn[j].GetComponentInChildren<TMP_Text>().text).sound, false);
|
|
//打开相应的子按钮
|
|
foreach (var item in JingLuoXueWeiDict)
|
|
{
|
|
item.Value.SetActive(false);
|
|
//if (item.Key.Equals(allBigBtn[j]))
|
|
//{
|
|
// this.Log("时间1");
|
|
// item.Value.SetActive(true);
|
|
//}
|
|
//else
|
|
//{
|
|
// this.Log("时间2");
|
|
|
|
// item.Value.SetActive(false);
|
|
//}
|
|
}
|
|
JingLuoXueWeiDict[allBigBtn[j]].SetActive(true);
|
|
///根据大按钮的名称在表格中查找到相应的子物体并进行实例化
|
|
CreateBtnAsName(allBigBtn[j]);
|
|
CreateTxtAsName(allBigBtn[j]);
|
|
//将穴位与文字变回红色
|
|
ChangeRedXueWeiAndTxt();
|
|
|
|
//关闭子按钮下的所有按钮的选中状态
|
|
foreach (var item in JingLuoXueWeiDict)
|
|
{
|
|
for (int i = 0; i < item.Value.transform.childCount; i++)
|
|
{
|
|
item.Value.transform.GetChild(i).GetComponent<BtnImage>().OnExitBtn();
|
|
}
|
|
}
|
|
//LayoutRebuilder.ForceRebuildLayoutImmediate(allBigBtn[j].transform.parent.GetComponent<RectTransform>());
|
|
//打开提示框
|
|
uiManager.CloseUI<TipSmallPanel>();
|
|
gameManager.uiManager.ShowUI<TipBigPanel>(null, btn.GetComponentInChildren<TMP_Text>().text);
|
|
}
|
|
else
|
|
{
|
|
allBigBtn[j].GetComponent<BtnImage>().OnExitBtn();
|
|
allBigBtn[j].GetComponent<BtnImage>().isOpen = false;
|
|
}
|
|
}
|
|
//LayoutRebuilder.ForceRebuildLayoutImmediate(btn.transform.parent.GetComponent<RectTransform>());
|
|
//StartCoroutine(UndateScrollView(btn.transform.parent.GetComponent<RectTransform>()));
|
|
LayoutRebuilder.MarkLayoutForRebuild(btn.transform.parent.GetComponent<RectTransform>());
|
|
}
|
|
else///当前按钮处于未选中状态
|
|
{
|
|
JingLuoXueWeiDict[btn].SetActive(false);
|
|
btn.GetComponent<BtnImage>().isOpen = false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据按钮的名字调用相应的大按钮的回调
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
public void EnterBigBtnCallBack(string name)
|
|
{
|
|
for (int i = 0; i < allBigBtn.Count; i++)
|
|
{
|
|
if (name.Equals(allBigBtn[i].GetComponentInChildren<TMP_Text>().text))
|
|
{
|
|
allBigBtn[i].onClick.Invoke();
|
|
}
|
|
}
|
|
//LayoutRebuilder.ForceRebuildLayoutImmediate(transform.FindFirst<RectTransform>("Content"));
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据按钮的名字调用相应的小按钮的回调
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
public void EnterSmallBtnCallBack(string name)
|
|
{
|
|
GameObject go = null;
|
|
for (int i = 0; i < allSmallBtn.Count; i++)
|
|
{
|
|
if (name.Equals(allSmallBtn[i].GetComponentInChildren<TMP_Text>().text))
|
|
{
|
|
go = allSmallBtn[i].gameObject;
|
|
allSmallBtn[i].onClick.Invoke();
|
|
//EventSystem.current.SetSelectedGameObject(allSmallBtn[i].gameObject);
|
|
}
|
|
}
|
|
//LayoutRebuilder.ForceRebuildLayoutImmediate(transform.FindFirst<RectTransform>("Content"));
|
|
StartCoroutine(InvokeUpdate(go));
|
|
}
|
|
|
|
IEnumerator InvokeUpdate(GameObject go)
|
|
{
|
|
yield return new WaitForSeconds(.05f);
|
|
ScrollRect sb = transform.FindFirst<ScrollRect>("Scroll View");
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(sb.transform.FindFirst<RectTransform>("Content"));
|
|
this.Log("修改前的值:" + sb.verticalNormalizedPosition);
|
|
sb.verticalNormalizedPosition = Math.Clamp(sb.verticalNormalizedPosition, 0, 1);
|
|
//sb.verticalNormalizedPosition = .5f;
|
|
this.Error("修改后的值" + sb.verticalNormalizedPosition);
|
|
//float height = sb.transform.FindFirst<RectTransform>("Content").localPosition.y;
|
|
//sb.transform.FindFirst<RectTransform>("Content").localPosition = new Vector2(0, go.transform.localPosition.y);
|
|
}
|
|
/// <summary>
|
|
/// 根据表格创建子按钮
|
|
/// </summary>
|
|
/// <param name="btn"></param>
|
|
public void CreateBtnAsName(Button btn)
|
|
{
|
|
if (!isCreateBtnLst.Contains(btn.GetComponentInChildren<TMP_Text>().text))
|
|
{
|
|
List<JingLuoSmall> all = gameModel.excelData.allJingLuoSmall;
|
|
for (int i = 0; i < all.Count; i++)
|
|
{
|
|
if (all[i].name.Equals(btn.GetComponentInChildren<TMP_Text>().text))
|
|
{
|
|
GameObject go = Resources.Load<GameObject>("SmallBtn");
|
|
GameObject obj = GameObject.Instantiate(go, JingLuoXueWeiDict[btn].transform);
|
|
obj.name = all[i].XueWeiName_NoPinYin;
|
|
obj.GetComponentInChildren<TMP_Text>().text = all[i].XueWeiName_NoPinYin;
|
|
Debug.Log($"创建成功:{all[i].XueWeiName_NoPinYin}");
|
|
Button creatBtn = obj.GetComponent<Button>();
|
|
int z = i;
|
|
creatBtn.onClick.AddListener(() =>
|
|
{
|
|
for (int i = 0; i < allBigBtn.Count; i++)
|
|
{
|
|
allBigBtn[i].GetComponent<BtnImage>().OnExitBtn();
|
|
}
|
|
|
|
foreach (var item in JingLuoXueWeiDict)
|
|
{
|
|
for (int i = 0; i < item.Value.transform.childCount; i++)
|
|
{
|
|
item.Value.transform.GetChild(i).GetComponent<BtnImage>().OnExitBtn();
|
|
}
|
|
}
|
|
creatBtn.GetComponent<BtnImage>().OnEnterBtn();
|
|
//穴位和文字变色
|
|
ChangeXueWeiAndTxt(creatBtn.GetComponentInChildren<TMP_Text>().text);
|
|
Game.Instance.sound.StopBGM();
|
|
Game.Instance.sound.PlayBGM(all[z].sound, false);
|
|
uiManager.CloseUI<TipBigPanel>();
|
|
uiManager.ShowUI<TipSmallPanel>(null, creatBtn.GetComponentInChildren<TMP_Text>().text);
|
|
});
|
|
allSmallBtn.Add(creatBtn);
|
|
}
|
|
}
|
|
// JingLuoXueWeiDict[btn].GetComponent<RectTransform>().ForceUpdateRectTransforms();
|
|
//cor = StartCoroutine(UndateScrollView(JingLuoXueWeiDict[btn].transform.GetComponent<RectTransform>()));
|
|
// LayoutRebuilder.ForceRebuildLayoutImmediate(JingLuoXueWeiDict[btn].transform.GetComponent<RectTransform>());
|
|
|
|
//LayoutRebuilder.ForceRebuildLayoutImmediate(btn.transform.parent.GetComponent<RectTransform>());
|
|
isCreateBtnLst.Add(btn.GetComponentInChildren<TMP_Text>().text);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据表格创建穴位Txt
|
|
/// </summary>
|
|
/// <param name="btn"></param>
|
|
public void CreateTxtAsName(Button btn)
|
|
{
|
|
if (!isCreateTxtLst.Contains(btn.GetComponentInChildren<TMP_Text>().text))
|
|
{
|
|
List<JingLuoSmall> all = gameModel.excelData.allJingLuoSmall;
|
|
for (int i = 0; i < all.Count; i++)
|
|
{
|
|
if (all[i].name.Equals(btn.GetComponentInChildren<TMP_Text>().text))
|
|
{
|
|
GameObject go = Resources.Load<GameObject>("穴位_Txt");
|
|
GameObject obj = GameObject.Instantiate(go, gameManager.transform.parent.FindFirst(all[i].gameObjectName).transform);
|
|
obj.name = all[i].XueWeiName_NoPinYin + all[i].gameObjectName;
|
|
obj.GetComponentInChildren<Text>().text = all[i].XueWeiName_NoPinYin;
|
|
allXueWei_Txt.Add(obj);
|
|
}
|
|
}
|
|
isCreateTxtLst.Add(btn.GetComponentInChildren<TMP_Text>().text);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 穴位和文字变色
|
|
/// </summary>
|
|
public void ChangeXueWeiAndTxt(string name)
|
|
{
|
|
//文字变色
|
|
for (int i = 0; i < allXueWei_Txt.Count; i++)
|
|
{
|
|
if (allXueWei_Txt[i].GetComponentInChildren<Text>().text.Equals(name))
|
|
{
|
|
allXueWei_Txt[i].GetComponentInChildren<Text>().color = new Color(0, 0, 1, 1);
|
|
}
|
|
else
|
|
{
|
|
allXueWei_Txt[i].GetComponentInChildren<Text>().color = new Color(0, 0, 0, 1);
|
|
}
|
|
}
|
|
|
|
//穴位变色
|
|
for (int i = 0; i < gameManager.allXueWeiRenderer.Count; i++)
|
|
{
|
|
//string na = gameModel.excelData.GetJingLuoSmallXueWeiName_NoPinYin(name).gameObjectName;
|
|
string na = gameModel.excelData.GetJingLuoSmallXueWeiName_NoPinYin(name).LightXueWeiName;
|
|
if (gameManager.allXueWeiRenderer[i].gameObject.name.Equals(na))
|
|
{
|
|
gameManager.allXueWeiRenderer[i].material = gameManager.blueMaterial;
|
|
}
|
|
else
|
|
{
|
|
gameManager.allXueWeiRenderer[i].material = gameManager.redMaterial;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 将穴位物体和文字变回红色
|
|
/// </summary>
|
|
public void ChangeRedXueWeiAndTxt()
|
|
{
|
|
//文字变色
|
|
for (int i = 0; i < allXueWei_Txt.Count; i++)
|
|
{
|
|
allXueWei_Txt[i].GetComponentInChildren<Text>().color = new Color(0, 0, 0, 1);
|
|
}
|
|
|
|
//穴位变色
|
|
for (int i = 0; i < gameManager.allXueWeiRenderer.Count; i++)
|
|
{
|
|
gameManager.allXueWeiRenderer[i].material = gameManager.redMaterial;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示选中的经络并隐藏其他经络
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
public void ActiveSelectJingLuo(string name)
|
|
{
|
|
for (int i = 0; i < gameManager.allJingLuoGame.Count; i++)
|
|
{
|
|
if (gameManager.allJingLuoGame[i].name.Equals(name))
|
|
{
|
|
gameManager.allJingLuoGame[i].SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
gameManager.allJingLuoGame[i].SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
IEnumerator UndateScrollView(RectTransform rect)
|
|
{
|
|
yield return null;
|
|
//LayoutRebuilder.MarkLayoutForRebuild(rect);
|
|
//LayoutRebuilder.ForceRebuildLayoutImmediate(rect);
|
|
yield return new WaitForSeconds(0.02f);
|
|
rect.gameObject.SetActive(false);
|
|
yield return new WaitForSeconds(0.02f);
|
|
rect.gameObject.SetActive(true);
|
|
}
|
|
}
|