Skip to main content

BakeTexturesFromTemplate

EZRecolorBaker.BakeTexturesFromTemplate()

public static BakeResult BakeTexturesFromTemplate(
GameObject prefab,
EZRecolorTemplate template,
string name,
bool addPrefabs = true,
List<EZRecolor.Objects.BakedPrefab> overridePrefabs = null,
EZRecolorComponent component = null,
bool useDialogErrorInstead = false,
bool useConsoleCompleteMsgInstead = false,
int returnBakedPrefabIndex = -1,
EZRecolor.Objects.BakedPrefab.Platform preferredReturnPlatform = EZRecolor.Objects.BakedPrefab.Platform.Unset
)

ParameterTypeDefaultDescription
prefabGameObjectThe prefab with the EZRecolor materials
templateEZRecolorTemplateThe template to use
namestringName of the recolor
addPrefabsbooltrueAdd the baked prefab into the scene once the bake is complete?
overridePrefabsList EZRecolor.Objects.BakedPrefabnullA list that can override which prefabs are baked (such as for the EZRecolor Component)
componentEZRecolorComponentnullIf baked through an EZRecolor Component, pass it here, else null
useDialogErrorInsteadboolfalseIf true, if the baker errors out due to Lite Edition limitations, display the error as a popup window. Else, just display it in the console
useConsoleCompleteMsgInsteadboolfalsePut the Completed Bake message in the console instead of a Dialog Windows
returnBakedPrefabIndexint-1This will return a specific Baked Prefab once baked. If -1, it'll take the one that is planned on being spawned in the scene. If anything else, it'll try to take the one at the index in the Baked Prefab's list in the Template, else default to the -1 behavior.
preferredReturnPlatformEZRecolor.Objects.BakedPrefab.PlatformEZRecolor.Objects.BakedPrefab.Platform.UnsetAllows to set a preferred Platform for the returned prefab in case the ID doesn't exist, and returns the first one found of the selected platform. Null if non-existent.

Returns: A Bake Result object containing all Baked Textures, Materials and Prefabs. Prefabs wise, if one fails to be created by the Baker, it will NOT be included in this returned Object.

Export an EZRecolor prefab into Textures, Materials and new Prefabs via an EZRecolor Template.


Example Usage

using UnityEngine;
using MikeDaBird.EZRecolor.Utilities.Editor;

class BakeFromScript : MonoBehavior{
public EZRecolorTemplate template;
public GameObject sourcePrefab;
public string name;

// Bake Textures using a Template and a Prefab, both set within the Component
public List<Texture2D> Bake(){
textures = EZRecolorBaker.BakeTexturesFromTemplate(sourcePrefab, template, name);
return textures;
}
}