x


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

more ▼

asked Mar 08 '11 at 07:03 PM

vagabondking gravatar image

vagabondking
1 2 2 4

please add your sample script which case this error

Mar 08 '11 at 07:07 PM robert 4

are you building for Android or iOS?

Dec 16 '12 at 10:08 PM ryanmillercg
(comments are locked)
10|3000 characters needed characters left

4 answers: sort newest

Rebooting my computer usually fixes this error, not sure what causes it but this looks to be a Unity bug (of course this is assuming that you do infact have the _MainTex property defined in your shader as I did).

If your computer crashed, you might want to manually delete the Temp folder from your project to make sure nothing is surviving the restart, maybe forcibly reimporting all assets in your project will be enough to fix this too, I have not tried though.

more ▼

answered Dec 16 '12 at 09:56 PM

kurifu gravatar image

kurifu
21 1 1 1

In some cases when you switch between different applications that access / write / read an asset it can occur that Unity can't access an asset while reimporting since the file got locked. This usually leads to an "empty" file in Unity. Usually reimporting of the file should fix it.

Dec 16 '12 at 10:20 PM Bunny83
(comments are locked)
10|3000 characters needed characters left

check the appropriate include in shader file for example

include "UnityCG.cginc"

include "AngryInclude.cginc"

etc

more ▼

answered Feb 29 '12 at 12:07 AM

TopTor gravatar image

TopTor
1

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jun 08 '11 at 07:57 PM

messyfresh gravatar image

messyfresh
1 1 1 2

(comments are locked)
10|3000 characters needed characters left

After a crash in Unity I got exactly the same message. Anyone found a fix for this?

more ▼

answered Jun 05 '11 at 09:17 PM

pepefirst gravatar image

pepefirst
30 11 14 21

(comments are locked)
10|3000 characters needed characters left

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" {}
}
more ▼

answered Mar 22 '11 at 09:40 PM

Andy Korth gravatar image

Andy Korth
66 5

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1679
x1478
x281
x276
x5

asked: Mar 08 '11 at 07:03 PM

Seen: 4962 times

Last Updated: Dec 16 '12 at 10:20 PM