CultivationOfBrewing/Assets/Scripts/UI/UIPanel/UI_ContentPanel.cs

83 lines
2.3 KiB
C#

using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class UI_ContentPanel : BasePanel
{
public static UI_ContentPanel instance;
public Image ContentPanel;
public Button enter;
public Button exit;
public TextMeshProUGUI ContentText;
public RawImage ContentrawImage;
public string Tips ;
protected override void Awake()
{
instance = this;
//foreach (var child in GetComponentsInChildren<TextMeshProUGUI>())
//{
// if (child.name.Equals("ContentText"))
// {
// ContentText = child as TextMeshProUGUI;
// }
//}
//ContentText = gameObject.transform.Find("ContentText").GetComponent<TextMeshProUGUI>();
//ContentPanel = GetControl<Image>("BG");
//enter = GetControl<Button>("³ö");
//exit = GetControl<Button>("½ø");
base.Awake();
}
public void init(TextMeshProUGUI textMeshProUGUI,Texture texture)
{
textMeshProUGUI.text = ContentText.text;
texture = ContentrawImage.texture;
}
public override void ShowMe()
{
base.ShowMe();
}
public override void HideMe()
{
Tips ="";
base.HideMe();
}
protected override void OnClick(string btnName)
{
Debug.Log(btnName);
switch (btnName)
{
case "exit":
if (ContentPanel.rectTransform.localPosition.x == 940)
{
ContentPanel.rectTransform.DOLocalMoveX(1330, 1f);
enter.gameObject.SetActive(true);
exit.gameObject.SetActive(false);
}
break;
case "enter":
if (ContentPanel.rectTransform.localPosition.x == 1330)
{
ContentPanel.rectTransform.DOLocalMoveX(940,1f);
enter.gameObject.SetActive(false);
exit.gameObject.SetActive(true);
}
break;
}
}
public void fizhi()
{
//for (int i = 0; i < Tips.Count; i++)
//{
// ContentText.text += Tips[i];
//}
ContentText.text = Tips;
}
}