#How to access MainTex in shadergraph

1 messages · Page 1 of 1 (latest)

abstract kite
#

Whenever I try to create a MainTex property in a shadergraph I get an error, stating that there's another property with the same name. I want to access it so that I can sample it in this canvas shader and read what the Image is displaying before modifying it.

tardy forum
#

For Canvas/UI shaders please use the UI shaders.
I believe you can sample _MainTex in a custom node otherwise without declaring it. There might be a node for it already, but I haven't worked with UI shaders in a while

abstract kite
void rivet
#

If you ignore that error and use the property does it actually break the shader?

abstract kite
#

It seems to work. The shader has access to whatever sprite is assigned the Image, without me needing to manually assign it in a material.
Its only when I open, modify, or save the shader that it spams the console with that error.

void rivet
#

You created the property as Texture2D right?

abstract kite
#

Yes. It also gives the error with both Global and Per Material

void rivet
#

Strange. Can't seem to replicate it. I'd maybe try restarting the project and see if it stops

#

If not maybe try a more up-to-date unity version / make a bug report

abstract kite
#

I'll try updating, as I'm probably a few versions behind

abstract kite
#

Updated to latest, 6000.0.58f1
Still the same error