Skip to content

How to Create a new Modifier

James Veugelaers edited this page Apr 5, 2025 · 4 revisions

A modifier is a step in the build process run after retrieving all sources. Modifiers will change the sources files in a cached directory.

The Build Uploader uses reflection to find all classes inheriting ABuildConfigModifer to display them in the games dropdown.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Wireframe
{
    internal class ExampleModifier : ABuildConfigModifer
    {
        public override bool IsSetup(out string reason)
        {
            // Check if the modifier is ready to start the build
            // If not, return false and set the reason as to why eg: "MyService not setup"
            reason = "";
            return true;
        }

        public override void Initialize(Action onChanged)
        {
            // Called when a modifier is created
            // onChanged is called when the modifier is changed so the UI can be refreshed
        }

        public override async Task<UploadResult> ModifyBuildAtPath(string cachedDirectory, BuildConfig buildConfig, int buildIndex)
        {
            // Modify the build at the given path that will always be a directory
            // Return UploadResult.Success() if successful
            // Return UploadResult.Failed("Error message") if failed
            return UploadResult.Success();
        }

        public override bool OnGUI()
        {
            // Draw the GUI for the modifier
            // Return true if the GUI was changed and needs to be saved
            return false;
        }

        public override Dictionary<string, object> Serialize()
        {
            // Save the modifier data to a save
            return new Dictionary<string, object>
            {
                { "exampleKey", "exampleValue" }
            };
        }

        public override void Deserialize(Dictionary<string, object> data)
        {
            // Load the modifier data from a save
            if (data.TryGetValue("exampleKey", out var value))
            {
                // Do something with the value
            }
        }
    }
}

Clone this wiki locally