滚动列表
This commit is contained in:
@@ -4,7 +4,7 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AibisDream
|
||||
namespace AibisDream.UI
|
||||
{
|
||||
public class ChapterPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
@@ -12,6 +12,8 @@ namespace AibisDream
|
||||
|
||||
public ChapterController chapterController;
|
||||
public Animator animator;
|
||||
public Image background;
|
||||
|
||||
public RectTransform chapterContentRect;
|
||||
public TMP_Text errorInfo;
|
||||
|
||||
@@ -24,7 +26,6 @@ namespace AibisDream
|
||||
|
||||
#endregion
|
||||
|
||||
public Color backgroundColor = new(10.0f / 255.0f, 10.0f / 255.0f, 10.0f / 255.0f, 0.6f);
|
||||
public float delayTime = 0.5f;
|
||||
private GameObject _background;
|
||||
|
||||
@@ -48,37 +49,14 @@ namespace AibisDream
|
||||
|
||||
private void AddBackground()
|
||||
{
|
||||
var bgTex = new Texture2D(1, 1);
|
||||
bgTex.SetPixel(0, 0, backgroundColor);
|
||||
bgTex.Apply();
|
||||
|
||||
_background = new GameObject("PopupBackground");
|
||||
var image = _background.AddComponent<Image>();
|
||||
var rect = new Rect(0, 0, bgTex.width, bgTex.height);
|
||||
var sprite = Sprite.Create(bgTex, rect, new Vector2(0.5f, 0.5f), 1);
|
||||
// Clone the material, which is the default UI material, to avoid changing it permanently.
|
||||
image.material = new Material(image.material);
|
||||
image.material.mainTexture = bgTex;
|
||||
image.sprite = sprite;
|
||||
var newColor = image.color;
|
||||
image.color = newColor;
|
||||
image.canvasRenderer.SetAlpha(0.0f);
|
||||
image.CrossFadeAlpha(1.0f, 0.4f, false);
|
||||
|
||||
var canvas = GetComponentInParent<Canvas>();
|
||||
_background.transform.localScale = new Vector3(1, 1, 1);
|
||||
_background.GetComponent<RectTransform>().sizeDelta = canvas.GetComponent<RectTransform>().sizeDelta;
|
||||
_background.transform.SetParent(transform, false);
|
||||
_background.transform.SetAsFirstSibling();
|
||||
background.canvasRenderer.SetAlpha(0.0f);
|
||||
background.gameObject.SetActive(true);
|
||||
background.CrossFadeAlpha(1.0f, 0.4f, false);
|
||||
}
|
||||
|
||||
private void RemoveBackground()
|
||||
{
|
||||
var image = _background.GetComponent<Image>();
|
||||
if (image != null)
|
||||
{
|
||||
image.CrossFadeAlpha(0.0f, 0.2f, false);
|
||||
}
|
||||
background.CrossFadeAlpha(0.0f, 0.2f, false);
|
||||
}
|
||||
|
||||
#region 绘制关卡信息部分
|
||||
@@ -119,6 +97,8 @@ namespace AibisDream
|
||||
chapterContentRect.DestroyAllChildren();
|
||||
gameObject.SetActive(false);
|
||||
Destroy(_background);
|
||||
|
||||
background.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void OnChapterSelected(ChapterVo chapterVo)
|
||||
|
||||
Reference in New Issue
Block a user