Skip to content

Asset APIs ​

Namespace: StellarStriderLib.Models. Call Unity asset APIs on the main thread. Examples: Models and materials.

Source: AssetScope.cs and ObjReader.cs.

MaterialKind ​

Enum values:

ValueBehaviour
NativeClone loaded native material by name
SolidClone native material and clear native atlas/palette textures for solid tinting
UnlitCreate a material using Universal Render Pipeline/Unlit

MaterialDefinition ​

PropertyTypeDefaultMeaning
KindMaterialKindSolidRendering mode
NativeNamestring"LogicGates"Source material for Native/Solid
TintUnityEngine.ColorwhiteMaterial tint
TextureResourcestringnullOptional embedded texture resource or ZIP-entry reference

Properties are public get/set. Native/Solid modes need the source material available among loaded Unity resources. Unlit needs the named shader. Texture loading uses the owning assembly's scope.

MeshDefinition ​

PropertyTypeDefaultMeaning
ResourcestringnullRequired embedded OBJ resource or ZIP-entry reference
PositionUnityEngine.Vector3zeroLocal position
RotationUnityEngine.Vector3zeroLocal Euler angles in degrees
ScaleUnityEngine.Vector3oneLocal visual scale
MaterialMaterialDefinitionnew default definitionMaterial settings

Properties are public get/set. Mesh scale does not resize explicit part physics or interaction boxes.

AssetScope ​

Obtained through ModRegistry.Assets; no public constructor. The scope owns assembly-specific resource access and caches.

Read ​

csharp
public byte[] Read(string resource);

Reads the owning assembly's embedded resource, for example MyFirstMod.cube.obj or MyFirstMod.assets.zip!models/cube.obj. Names must match exactly; missing resources throw. Returns fresh bytes.

Mesh ​

csharp
public UnityEngine.Mesh Mesh(string resource);

Loads an OBJ, caches it by resource string, and returns the shared cached mesh. Calls ObjReader.ParseObj internally. Missing/invalid resources fail construction when used by a prefab.

Texture ​

csharp
public UnityEngine.Texture2D Texture(string resource);

Loads and caches an image by resource string. Missing resources and invalid image data throw. Use embedded PNG/JPEG assets. Wallpaper loading catches failures and skips those images.

Material ​

csharp
public UnityEngine.Material Material(MaterialDefinition definition);

Creates or retrieves a material keyed by mode, native name, texture resource, and tint. Passing null uses default material settings. A missing native source material throws. Cached materials are shared within this scope.

AddMesh ​

csharp
public UnityEngine.GameObject AddMesh(UnityEngine.Transform parent, MeshDefinition definition);

Creates a child with the parent's layer, local transforms, mesh filter, and renderer. Returns the GameObject. Adds no collider and does not call ConfigureMesh.

Ownership ​

SSLib owns cached assets and releases them on shutdown. Do not destroy or mutate shared assets. Generated prefab children follow their parent/world lifetime; manage separately created objects yourself.

Clear your own references on world teardown. There is no public cache-release method.

ObjReader ​

csharp
public static UnityEngine.Mesh ParseObj(string text);

Parses OBJ text into a new Unity mesh without using an AssetScope cache. It reflects X and reverses face winding, supports primary and extended palette UVs, preserves supplied normals, recalculates missing normals, resolves negative indices, and triangulates polygons.

The caller owns this mesh and must destroy it when finished. This method creates a Unity object, so call it on the main thread even though you are supplying text directly.

StellarStriderLib documentation · Mods for StellarDrive