74 lines
2.1 KiB
C#
74 lines
2.1 KiB
C#
// Copyright (c) Pixel Crushers. All rights reserved.
|
|
|
|
|
|
using PixelCrushers;
|
|
using PixelCrushers.QuestMachine;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Beyond
|
|
{
|
|
|
|
/// <summary>
|
|
/// Unity UI template for foldouts.
|
|
/// </summary>
|
|
|
|
public class bUnityUIFoldoutTemplate : UnityUIContentTemplate
|
|
{
|
|
[SerializeField] private QuestImageData imageData;
|
|
[SerializeField]
|
|
private UnityEngine.UI.Button m_foldoutButton;
|
|
|
|
[SerializeField]
|
|
private UITextField m_foldoutText;
|
|
|
|
public Image image;
|
|
|
|
[SerializeField]
|
|
private RectTransform m_interiorPanel;
|
|
|
|
public UnityEngine.UI.Button foldoutButton
|
|
{
|
|
get { return m_foldoutButton; }
|
|
set { m_foldoutButton = value; }
|
|
}
|
|
|
|
public UITextField foldoutText
|
|
{
|
|
get { return m_foldoutText; }
|
|
set { m_foldoutText = value; }
|
|
}
|
|
|
|
public RectTransform interiorPanel
|
|
{
|
|
get { return m_interiorPanel; }
|
|
set { m_interiorPanel = value; }
|
|
}
|
|
|
|
protected UnityUIInstancedContentManager contentManager { get; set; }
|
|
|
|
public virtual void Awake()
|
|
{
|
|
if (foldoutButton == null && Debug.isDebugBuild) Debug.LogError("Quest Machine: Foldout Button is unassigned.", this);
|
|
if (UITextField.IsNull(foldoutText) && Debug.isDebugBuild) Debug.LogError("Quest Machine: Foldout Text is unassigned.", this);
|
|
if (interiorPanel == null && Debug.isDebugBuild) Debug.LogError("Quest Machine: Interior Panel is unassigned.", this);
|
|
}
|
|
|
|
public void Assign(string text, bool expanded)
|
|
{
|
|
image.sprite = imageData.GetImageFrom(text);
|
|
if (contentManager == null) contentManager = new UnityUIInstancedContentManager();
|
|
contentManager.Clear();
|
|
name = text;
|
|
foldoutText.text = text;
|
|
interiorPanel.gameObject.SetActive(expanded);
|
|
}
|
|
|
|
public void ToggleInterior()
|
|
{
|
|
interiorPanel.gameObject.SetActive(!interiorPanel.gameObject.activeSelf);
|
|
}
|
|
|
|
}
|
|
}
|