Skip to content

Mod Vehicles and Custom Colors

Michael Neises edited this page Oct 4, 2023 · 1 revision

In order to leverage the (optional) custom-color-picking features of Vehicle Framework, you must fulfill three promises to Vehicle Framework.

Vehicle Framework requires these things to be successful. Their purpose is so that Vehicle Framework can deliver a common interface for customizing the color of any Mod Vehicle. In other words, in each Mod Vehicle, you might find this same panel with buttons you can use to recolor your vehicle.

Three Promises

  1. You must provide a GameObject called "ColorPicker" when you implement your ModVehicle class.
  2. You must name materials you wish to color one of the following:
  • MainExterior
  • PrimaryAccent
  • SecondaryAccent
  • NameLabel
  1. You must implement four functions to actually do "the repainting" of your vehicle. (for now, sorry it's so many)

More about Promise 1

This ColorPicker object should be an empty transform, but that's not important. What matters is that the position and rotation (relative to your vehicle) are what you want them to be. The ColorPicker will naively replace this GameObject. Be careful you don't put it on backwards, or else it might not be visible!

More about Promise 2

Your material names must fall into one of these four names exactly. This is so that the display on the color picker itself will match what happens on the outside of your vehicle. In other words, the color picker can support only and exactly these four materials. The first three speak for themselves, I think. The NameLabel material will actually have your vehicle's name on it. (I wish I knew a better way to do this, but placing text over objects in 3D via a mod was quite hard to do.) Yes, the text of the name must be a part of the material itself. You will worry about how that happens as you fulfill promise 3.

More about Promise 3

Here are the functions in question.

public override void PaintVehicleSection(string materialName, Color col) PaintVehicleSection takes a material name and color, and it applies that color to every part of your vehicle that has the so-named material.

public override void PaintVehicleName(string name, Color nameColor, Color hullColor) PaintVehicleName takes the desired name as a string, the desired color of the name-text, and the desired color of the background text. It then paints the name as described onto those parts of your ship bearing the NameLabel material. This is perhaps the most difficult part of this procedure. You can see how I did it for the Odyssey in the source here.

public override void PaintNameDefaultStyle(string name) This function is quite simple because it just needs to call PaintVehicleName with some default parameters.

public override void PaintVehicleDefaultStyle(string name) This function should reset the vehicle to its original coloring. The functions here mostly operate over simple colors. If you want to provide a more complex coloring for your vehicle, it should be reapplied by this function.