Click or drag to resize

LoadAssetsLoadTexture Method

Load texture (*.dds, *.jpg, *.png, *.tga) from mod assets folder

Namespace:  MSCLoader
Assembly:  MSCLoader (in MSCLoader.dll) Version: 1.1.6.191
Syntax
C#
public static Texture2D LoadTexture(
	Mod mod,
	string fileName,
	bool normalMap = false
)
Request Example View Source

Parameters

mod
Type: MSCLoaderMod
Mod instance.
fileName
Type: SystemString
File name to load from assets folder (for example "texture.dds")
normalMap (Optional)
Type: SystemBoolean
Normal mapping (default false)

Return Value

Type: Texture2D
Returns unity Texture2D
Examples
You need to enter file name from your mod's asset folder.
Example for change texture when we press key
 1using MSCLoader;
 2using UnityEngine;
 3
 4public class ExampleMod : Mod
 5{
 6    //standard mod variables
 7    public override string ID => "ExampleMod";
 8    public override string Name => "LoadTexture Example";
 9    public override string Author => "SuperDrunkGuy6669";
10    public override string Version => "1.0";
11
12    //We need to use assets folder to load texture from.
13    public override bool UseAssetsFolder => true;
14
15    //Unity variables
16    GameObject gauge; 
17    Texture2D tex;
18
19    public override void Update()
20    {
21        //If we press F8, change texture
22        if (Input.GetKeyDown(KeyCode.F8))
23        {
24            tex = LoadAssets.LoadTexture(this, "extra_gauges.tex.dds");
25            gauge = GameObject.Find("extra gauges(xxxxx)");
26            foreach (Transform child in gauge.transform)
27            {
28                child.gameObject.GetComponent<Renderer>().material.mainTexture = tex;
29            }
30        }
31    }
32}
See Also