Show / Hide Table of Contents

Class ModTexture

A texture mod resource.

Inheritance
Object
ModResource
ModTexture
Inherited Members
ModResource.GetTexture(String)
ModResource.GetMesh(String)
ModResource.GetAudioClip(String)
ModResource.GetAssetBundle(String)
ModResource.Get(ResourceReference)
ModResource.CreateTextureResource(String, String, Boolean, Boolean)
ModResource.CreateMeshResource(String, String, Boolean)
ModResource.CreateAudioClipResource(String, String, Boolean)
ModResource.CreateAssetBundleResource(String, String, Boolean)
ModResource.SetOnObject(GameObject, Action<GameObject>, Action)
ModResource.TriggerOnLoad()
ModResource.AllResourcesLoaded
ModResource.Type
ModResource.Name
ModResource.Available
ModResource.OnResourceLoaded
ModResource.OnAllResourcesLoaded
ModResource.OnLoad
Namespace: Modding
Assembly: Assembly-CSharp.dll
Syntax
public class ModTexture : ModResource

Properties

Error

Declaration
public override string Error { get; }
Property Value
Type Description
String
Overrides
ModResource.Error

HasError

Declaration
public override bool HasError { get; }
Property Value
Type Description
Boolean
Overrides
ModResource.HasError

Loaded

Declaration
public override bool Loaded { get; }
Property Value
Type Description
Boolean
Overrides
ModResource.Loaded

Texture

Declaration
public Texture2D Texture { get; }
Property Value
Type Description
UnityEngine.Texture2D

Methods

SetOnObject(GameObject, Material, Action<GameObject>, Action)

SetOnObject is a utility method that easily allows handling long resource loading times. This overload also sets a given MateriaL.

Declaration
public void SetOnObject(GameObject go, Material mat, Action<GameObject> postSetAction = null, Action prefabPostSetAction = null)
Parameters
Type Name Description
UnityEngine.GameObject go

Object on which to set the resource.

UnityEngine.Material mat

Material which should be set on the renderers.

Action<UnityEngine.GameObject> postSetAction

Callback for every object that is set.

Action prefabPostSetAction

Callback for the original object.

Remarks

When SetOnObject is called on an object, an OnLoad handler for the resource is installed that will automatically set the appropriate value (renderer.material.mainTexture for a ModTexture, meshFilter.mesh for a ModMesh, and audioSource.clip for a ModAudioClip) when the resource is done loading.

However, the major benefit of using SetOnObject is that it will also automatically handle the given GameObject being instantiated/copied. All instances of the object will also automatically receive the resource.

The two optional callbacks can be used to perform additional actions that are necessary to correctly set the resource. The first one is called for every object on which the resource is set (including the original object), and the second one only for the object originally passed into the function.

In this overload, an additional Material is passed in, which will also be set on the renderers, in addition to the texture.

Operators

Explicit(Texture2D to ModTexture)

Declaration
public static explicit operator ModTexture(Texture2D texture)
Parameters
Type Name Description
UnityEngine.Texture2D texture
Returns
Type Description
ModTexture

Implicit(ModTexture to Texture2D)

Declaration
public static implicit operator Texture2D(ModTexture texture)
Parameters
Type Name Description
ModTexture texture
Returns
Type Description
UnityEngine.Texture2D
Back to top Generated by DocFX