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:
| Value | Behaviour |
|---|---|
Native | Clone loaded native material by name |
Solid | Clone native material and clear native atlas/palette textures for solid tinting |
Unlit | Create a material using Universal Render Pipeline/Unlit |
MaterialDefinition
| Property | Type | Default | Meaning |
|---|---|---|---|
Kind | MaterialKind | Solid | Rendering mode |
NativeName | string | "LogicGates" | Source material for Native/Solid |
Tint | UnityEngine.Color | white | Material tint |
TextureResource | string | null | Optional 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
| Property | Type | Default | Meaning |
|---|---|---|---|
Resource | string | null | Required embedded OBJ resource or ZIP-entry reference |
Position | UnityEngine.Vector3 | zero | Local position |
Rotation | UnityEngine.Vector3 | zero | Local Euler angles in degrees |
Scale | UnityEngine.Vector3 | one | Local visual scale |
Material | MaterialDefinition | new default definition | Material 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
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
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
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
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
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
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.