Created
January 15, 2022 08:40
-
-
Save elringus/91b288ba07a02f7daf649a28a0f028a3 to your computer and use it in GitHub Desktop.
Assign main texture property via the BlendModeEffect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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