Repository navigation
Using ModAPI in your mod
DipCrai edited this page Jun 21, 2024
·
7 revisions
using UnityEngine;
using WorldBoxModLoader.ModAPI;
namespace SampleMod
{
public class Mod
{
public static void Main()
{
GameObject sampleObject = new GameObject("SampleObject");
SpriteRenderer spriteRenderer = sampleObject.AddComponent<SpriteRenderer>();
Texture2D texture = Utils.LoadTexture("texture.png");
spriteRenderer.material.SetTexture("_NORMALMAP", texture);
}
}
}using UnityEngine;
using WorldBoxModLoader.ModAPI;
namespace SampleMod
{
public class Mod
{
public static void Main()
{
GameObject sampleObject = new GameObject("SampleObject");
SpriteRenderer spriteRenderer = sampleObject.AddComponent<SpriteRenderer>();
spriteRenderer.sprite = Utils.LoadSprite("sprite.png");
}
}
}using UnityEngine;
using WorldBoxModLoader.ModAPI;
namespace SampleMod
{
public class Mod
{
public static void Main()
{
GameObject sampleObject = new GameObject("SampleObject");
AudioSource audioSource = sampleObject.AddComponent<AudioSource>();
audioSource.clip = Utils.LoadSound("sound.mp3");
}
}
}Utils.CreateSimplePowerButton([NotNull] string buttonName, UnityAction buttonAction, Sprite buttonIcon)
using UnityEngine;
using WorldBoxModLoader.ModAPI;
namespace SampleMod
{
public class Mod
{
public static void Main()
{
GameObject sampleObject = new GameObject("SampleObject");
SampleComponent sampleComponent = sampleObject.AddComponent<SampleComponent>();
PowerButton powerButton = Utils.CreateSimplePowerButton("Multiplayer menu", sampleComponent.Toggle, Utils.LoadSprite("icon.png"));
PowersTab powersTab = Utils.GetTab("Tab_Main");
Utils.AddButtonToTab(powerButton, powersTab, Vector2.zero);
}
}
public class SampleComponent : MonoBehaviour
{
public void Toggle()
{
gameObject.active = !gameObject.active;
}
}
}using WorldBoxModLoader.ModAPI;
namespace SampleMod
{
public class Mod
{
public static void Main()
{
PowersTab powersTab = Utils.CreateTab("TabName", "Sample Title", Utils.LoadSprite("TabIcon.png"));
}
}
}