Open An4r3w opened 2 years ago
using System;
using System.Linq;
using System.Collections.Generic;
using UnityEngine;
public class CategoryBuilder
{
/// <summary>
/// Use this method to create your own category.
/// </summary>
/// <param name="name">New category name</param>
/// <param name="description">Description of the new category</param>
/// <param name="icon">New category icon</param>
public static void Create(string name, string description, Sprite icon)
{
CatalogBehaviour manager = UnityEngine.Object.FindObjectOfType<CatalogBehaviour>();
if (manager.Catalog.Categories.FirstOrDefault((Category c) => c.name == name) == null)
{
Category category = ScriptableObject.CreateInstance<Category>();
category.name = name;
category.Description = description;
category.Icon = icon;
Category[] NewCategories = new Category[manager.Catalog.Categories.Length + 1];
Category[] categories = manager.Catalog.Categories;
for (int i = 0; i < categories.Length; i++)
{
NewCategories[i] = categories[i];
}
NewCategories[NewCategories.Length - 1] = category;
manager.Catalog.Categories = NewCategories;
}
}
}
copy and paste all of the first code into a clean .cs file and call it CategoryBuilder
CategoryBuilder.Create("NameOfCategory", "DescriptionOfCategory", ModAPI.LoadSprite("ImageOfCategory.png"));
create another .cs file and call it script.cs, then you use the basic entry point code and paste this line inside Main.
Make sure your mod.json file have this line below Scripts
"CategoryBuilder.cs",
If you want to add custom content to the category just find the category u created
CategoryOverride = ModAPI.FindCategory("CustomCategorynamegoeshere"),
Hello, first of all thank you so much. I have another question tho, what size must be the category icon? Can i add color to it?
how can i add a category for all my custom humans guns and objects?