Files
Continentis/Assets/OtherPlugins/Feel/MMTools/Accessories/MMGUI/MMSceneName.cs

40 lines
974 B
C#
Raw Normal View History

2026-03-20 11:56:50 -04:00
#if MM_UI
using UnityEngine;
2025-10-03 00:02:43 -04:00
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace MoreMountains.Tools
{
/// <summary>
2026-03-20 11:56:50 -04:00
/// This component, when added on a Text component, will display the name of the level
2025-10-03 00:02:43 -04:00
/// </summary>
public class MMSceneName : MonoBehaviour
2026-03-20 11:56:50 -04:00
{
protected Text _text;
2025-10-03 00:02:43 -04:00
2026-03-20 11:56:50 -04:00
/// <summary>
/// On Awake, stores the Text component
/// </summary>
protected virtual void Awake()
{
_text = gameObject.GetComponent<Text>();
}
2025-10-03 00:02:43 -04:00
2026-03-20 11:56:50 -04:00
/// <summary>
/// On Start, sets the level name
/// </summary>
protected virtual void Start()
{
SetLevelNameText();
}
2025-10-03 00:02:43 -04:00
2026-03-20 11:56:50 -04:00
/// <summary>
/// Assigns the level name to the Text
/// </summary>
public virtual void SetLevelNameText()
{
if (_text != null) _text.text = SceneManager.GetActiveScene().name;
}
}
2025-10-03 00:02:43 -04:00
}
#endif