Skip to content

Instantly share code, notes, and snippets.

@elringus
Created January 15, 2022 08:40
Show Gist options
  • Save elringus/91b288ba07a02f7daf649a28a0f028a3 to your computer and use it in GitHub Desktop.
Save elringus/91b288ba07a02f7daf649a28a0f028a3 to your computer and use it in GitHub Desktop.
Assign main texture property via the BlendModeEffect
using BlendModes;
using UnityEngine;
[RequireComponent(typeof(BlendModeEffect))]
public class SetTextureProperty : MonoBehaviour
{
public Texture2D Texture;
[ContextMenu("Set Texture")]
public void SetTexture ()
{
var blendModeEffect = GetComponent<BlendModeEffect>();
blendModeEffect.GetComponentExtension<ComponentExtension>().GetShaderProperty("_MainTex").SetValue(Texture);
blendModeEffect.SetMaterialDirty();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment