Firstborn/Assets/ModTool/Example/ModItem.cs
Schaken-Mods 7502018d20 Adding Mod Support
There is an asset in the store I grabbed. the coding is WAY above my head, I got about half of it and integrated and adapted what I can to it. im going as far as I can with it and ill come back in a few month when I understand t better.
2023-05-13 22:01:48 -05:00

50 lines
1023 B
C#

using UnityEngine;
using UnityEngine.UI;
using ModTool;
using TMPro;
public class ModItem : MonoBehaviour {
[SerializeField] public TextMeshProUGUI modName;
[SerializeField] public TextMeshProUGUI modInfo;
public Text modType;
public Toggle toggle;
public Mod mod;
/// <summary>
/// Initialze this ModItem with a Mod and ModMenu.
/// </summary>
/// <param name="mod"></param>
/// <param name="modMenu"></param>
public void Initialize(Mod mod)
{
this.mod = mod;
modName.text = mod.name;
modType.text = mod.contentType.ToString();
toggle.isOn = mod.isEnabled;
toggle.onValueChanged.AddListener( value => Toggle(value));
}
/// <summary>
/// Toggle whether the mod should be loaded
/// </summary>
public void Toggle(bool isEnabled)
{
mod.isEnabled = isEnabled;
}
/// <summary>
/// Enable or disable this ModItem's toggle.
/// </summary>
/// <param name="interactable"></param>
public void SetToggleInteractable(bool interactable)
{
toggle.interactable = interactable;
}
}