🔧
Modules
  • Modules
  • Module Container
  • Scripting
    • Creating new Modules
    • Changing Modules Runtime
  • Other stuff
    • Modular 3D Text
    • Modular 3D Layout
    • Package Importer
Powered by GitBook
On this page
  1. Scripting

Creating new Modules

PreviousModule ContainerNextChanging Modules Runtime

Last updated 1 year ago

To create modules, you have to understand how the VariableHolder class work.

The Variable holder contains two main parts. ✅ What type of variable? ✅ The value of the variable.

Modules contain a list of VariableHolder. For example, one for the duration, one for the animation curve, etc. This kind of structure allows an easier way to modify the module for each use case.

You can access them by their index in the list and by taking the type of data stored. Example: moduleContainer.variableHolders[0].floatValue

using System.Collections;
using UnityEngine;
using TinyGiantStudio.Modules;

[CreateAssetMenu(menuName = "YourModules/Module Name")]
public class YourModule : Module
{
    public override IEnumerator ModuleRoutine(GameObject obj, VariableHolder[] variableHolders)
    {
        //Do your stuff here
    }

    public override string VariableWarnings(VariableHolder[] variableHolders)
    {
        string warning = string.Empty;

        if (variableHolders == null)
                return warning;

        if (variableHolders.Length < 1)
                return warning;
        
        //Add your warning here
        //warning = AddWarning("Please specify a particle prefab to spawn.", warning);
        return warning;
    }
}

This is how the backend of a list of variable holder looks on a Module.
This is how that looks in the text or on other elements.