侧边栏配置
This commit is contained in:
@@ -603,11 +603,17 @@ namespace AibisDream
|
||||
public string[] states;
|
||||
|
||||
public string buttonImagePath;
|
||||
public string detailImagePath;
|
||||
|
||||
public Sprite GetButtonImage()
|
||||
{
|
||||
return ResourceKit.LoadAssetSync<Sprite>(buttonImagePath);
|
||||
}
|
||||
|
||||
public Sprite GetDetailImage()
|
||||
{
|
||||
return ResourceKit.LoadAssetSync<Sprite>(detailImagePath);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace AibisDream
|
||||
{
|
||||
public class ShapeCreateButton : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Image _image;
|
||||
[SerializeField] private TMP_Text _text;
|
||||
[SerializeField] private Button _button;
|
||||
|
||||
public UnityEvent OnClicked => _button.onClick;
|
||||
|
||||
public void SetInfo(BlockShapeInfo blockShapeInfo)
|
||||
{
|
||||
_image.sprite = blockShapeInfo.GetButtonImage();
|
||||
_text.text = blockShapeInfo.shapeName;
|
||||
gameObject.name = blockShapeInfo.shapeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3b75d4d7deddb249ad8509da83ced4b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,69 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UnityEngine.Events;
|
||||
using AibisDream.UI;
|
||||
|
||||
namespace AibisDream
|
||||
{
|
||||
[RequireComponent(typeof(BaseButton))]
|
||||
public class ShapeCreateButton : MonoBehaviour
|
||||
{
|
||||
[Header("组件索引")]
|
||||
[SerializeField] private Image backgroundImage;
|
||||
[SerializeField] private Image textBgImage;
|
||||
[SerializeField] private Image signImage;
|
||||
[SerializeField] private TMP_Text text;
|
||||
[SerializeField] private BaseButton button;
|
||||
|
||||
[Header("颜色配置")]
|
||||
[SerializeField] private ColorTint bgColor;
|
||||
[SerializeField] private ColorTint textBgColor;
|
||||
|
||||
public UnityEvent OnClicked => button.onClick;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
button.onStateTransition.AddListener(OnStateTransition);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
button.onStateTransition.RemoveListener(OnStateTransition);
|
||||
}
|
||||
|
||||
public void SetInfo(BlockShapeInfo blockShapeInfo)
|
||||
{
|
||||
signImage.sprite = blockShapeInfo.GetButtonImage();
|
||||
text.text = blockShapeInfo.shapeName;
|
||||
gameObject.name = blockShapeInfo.shapeName;
|
||||
}
|
||||
|
||||
private void OnStateTransition(SelectionType type, bool instant)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SelectionType.Normal:
|
||||
backgroundImage.color = bgColor.normalColor;
|
||||
textBgImage.color = textBgColor.normalColor;
|
||||
break;
|
||||
case SelectionType.Highlighted:
|
||||
backgroundImage.color = bgColor.highlightedColor;
|
||||
textBgImage.color = textBgColor.highlightedColor;
|
||||
break;
|
||||
case SelectionType.Pressed:
|
||||
backgroundImage.color = bgColor.pressedColor;
|
||||
textBgImage.color = textBgColor.pressedColor;
|
||||
break;
|
||||
case SelectionType.Selected:
|
||||
backgroundImage.color = bgColor.selectedColor;
|
||||
textBgImage.color = textBgColor.selectedColor;
|
||||
break;
|
||||
case SelectionType.Disabled:
|
||||
backgroundImage.color = bgColor.disabledColor;
|
||||
textBgImage.color = textBgColor.disabledColor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream.UI
|
||||
{
|
||||
[Serializable]
|
||||
public struct ColorTint
|
||||
{
|
||||
public Color normalColor;
|
||||
public Color highlightedColor;
|
||||
public Color pressedColor;
|
||||
public Color selectedColor;
|
||||
public Color disabledColor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 305426dc9855ad64b8dd06653dd2994e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user