Class PrefabUtils
A small collection of prefab related utilities.
public static class PrefabUtils
- Inheritance
-
PrefabUtils
- Inherited Members
Methods
AddBasicComponents(GameObject, string, TechType, CellLevel)
Adds and configures the following components on the
- PrefabIdentifier: Required for an object to be considered a prefab.
- TechTag: Required for inventory items, crafting, scanning, etc.
- LargeWorldEntity: Required for objects to persist after saving and exiting.
- SkyApplier: Added if Renderers exist in the hierarchy. Applies the correct lighting onto an object.
prefab.
- PrefabIdentifier: Required for an object to be considered a prefab.
- TechTag: Required for inventory items, crafting, scanning, etc.
- LargeWorldEntity: Required for objects to persist after saving and exiting.
- SkyApplier: Added if Renderers exist in the hierarchy. Applies the correct lighting onto an object.
public static void AddBasicComponents(GameObject prefab, string classId, TechType techType, LargeWorldEntity.CellLevel cellLevel)
Parameters
prefabGameObject- The prefab to operate on.
classIdstring- The class ID associated with the specified prefab.
techTypeTechType- Ignored if TechType.None is inputted.
cellLevelLargeWorldEntity.CellLevel- Level of distance this prefab can stay visible before unloading.
AddConstructable(GameObject, TechType, ConstructableFlags)
Adds and configures the Constructable component on the specified prefab.
public static Constructable AddConstructable(GameObject prefab, TechType techType, ConstructableFlags constructableFlags)
Parameters
prefabGameObject- The prefab to operate on.
techTypeTechType- The tech type associated with the specified prefab.
constructableFlagsConstructableFlags- A bitmask comprised of one or more ConstructableFlags that specify how the prefab should be treated during placement.
Returns
- Constructable
- The added constructable component.
AddVFXFabricating(GameObject, string, float, float, Vector3, float, Vector3)
Adds the VFXFabricating component onto the child found by
pathToModel.public static VFXFabricating AddVFXFabricating(GameObject prefabRoot, string pathToModel, float minY, float maxY, Vector3 posOffset = default, float scaleFactor = 1, Vector3 eulerOffset = default)
Parameters
prefabRootGameObject- The prefab object that this is applied to.
pathToModelstring- Leave as null or empty to point to the prefab root. Otherwise this is the path to the crafting model Transform, relative to the prefab's root Transform. For example, the Repair Tool's would be `welder_scaled/welder`.
minYfloatThe relative y position of where the ghost effect begins, in global coordinates relative to the model's center, taking the
posOffsetinto account.Typically a negative value because the bottom of an object is below its center. You may need to adjust this at runtime with Subnautica Runtime Editor to get desired results.
maxYfloatThe relative y position of where the ghost effect ends, in global coordinates relative to the model's center, taking the
posOffsetinto account.Typically a positive value because the top of an object is above its center. You may need to adjust this at runtime with Subnautica Runtime Editor to get desired results.
posOffsetVector3- The offset of the model when being crafted (in METERS). This is generally around zero, but the y value may be ajusted up or down a few millimeters to fix clipping/floating issues.
scaleFactorfloat- The relative scale of the model. Generally is 1x for most items.
eulerOffsetVector3- Rotational offset.
Returns
- VFXFabricating
- The added component.