- Home /
Material doesn't have a texture property '_MainTex'
I'm getting loads of error messages that say
Material doesn't have a texture property '_MainTex'
UnityEditor.DockArea:OnGUI()
I dug into the Editor logs and the precise message is
[/Applications/buildAgent/work/6bc5f79e0a4296d6/Runtime/Shaders/Material.cpp line 562] (Filename: /Applications/buildAgent/work/6bc5f79e0a4296d6/Runtime/Shaders/Material.cpp Line: 562)
Material doesn't have a texture property '_MainTex' UnityEngine.DetailRenderer:Render(Camera, Single, Int32, Single) UnityEngine.Terrain:CullAllTerrains(Int32) UnityEditor.Handles:Internal_DrawCameraWithGrid(Camera, Int32, DrawGridParameters&) UnityEditor.Handles:DrawCameraImpl(Rect, Camera, DrawCameraMode, Boolean, DrawGridParameters, Boolean) UnityEditor.Handles:DrawCameraStep1(Rect, Camera, DrawCameraMode, DrawGridParameters) UnityEditor.SceneView:OnGUI() System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&) System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) System.Reflection.MethodBase:Invoke(Object, Object[]) UnityEditor.HostView:Invoke(String, Object) UnityEditor.HostView:Invoke(String) UnityEditor.DockArea:OnGUI()
They stop if i delete the terrain, but persist even with a new terrain in a new scene. I'm sure I could work around this, but I'm curious now and want to track down why this is breaking. I have updated the project from pre-Unity3 to the current version, but wasn't getting this error before. Alternatively, does anyone have a way to hone in on materials/prefabs/assets that are causing problems within a project without moving or disrupting the whole project? Can you selectively disable them or something?
Thanks for your help
dylan
Answer by JAAMY · Jun 12, 2019 at 12:12 PM
if you are using a SRP ( unity shader graph ) , open your graph in its graph window, then add a property with type of Texture2D then name it : "_MainTex" and also name it's reference to "_MainTex".
But Important : Remember to uncheck the button called "Exposed", save your asset and you should be fine. you don't need to use this new Property
For me, the last part was the opposite. I had to check Exposed to get rid of the error, idk why. Just pointing this in case someone finds it helpful.
Answer by Andy Korth · Mar 22, 2011 at 09:40 PM
It's probably named something else in your shader.. or your shader doesn't have a _MainTex
Check your shader for a line like this:
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
restarting unity worked for me.
http://answers.unity3d.com/questions/126458/material-doesnt-have-a-texture-property-.html
Answer by DuckOfDoom · Jun 09, 2013 at 02:11 PM
I know this question is really old but I found a way to diagnose this error. You have to find your shader in project tab, select it and in inspector you will see an error. Then you can click "Open compiled shader" and it can give you clues about where the error is. I often mistype things and this helps me find errors.
DuckOfDoom, thanks (I can't upvote because of low rate)! Sometimes Unity Editor doesn't log error to console so we need to check shader tab.
Answer by pepefirst · Jun 05, 2011 at 09:17 PM
After a crash in Unity I got exactly the same message. Anyone found a fix for this?
Answer by messyfresh · Jun 08, 2011 at 07:57 PM
Its all dependent on the shader you are using. I started with OpenGL ES1.1, then changed to OpenGL2.0. After i switched i noticed i was still getting the error. I had to change the graphics emulation properties under the edit menu to OpenGL ES2.0 and now the problem is gone. Im not sure if its a complete fix or not, but i dont get the error anymore. Hope this helps.
Your answer
Follow this Question
Related Questions
GetAssetPath returning incomplete path for default materials 1 Answer
why shadows dont appear until i get close to them with the camera? 1 Answer
Tree color variation 0 Answers
Terrain Assets Error!! 1 Answer
Paint terrain paints all terrain? 0 Answers