- Home /
The question is answered, right answer was accepted
Can't edit materials anymore
I did something and now none of the materials in my project can be edited anymore. All I can change in the material inspector is the shader, below that there's just an empty grey area. I have the problem both if I view the material itself in the inspector and if I view a gameobject with that material attached (which brings up a small popup at the bottom of the inspector).
The problem persists for every shader and every material, even the ones in the Standard Assets package. Materials created before the problem do keep the settings I gave them (textures, colors etc.), I just can't edit them anymore. The problem isn't restricted to one scene but to the project: if I switch scenes it persists, but if I switch to a different (older or newer, doesn't matter) project I can suddenly edit materials. This doesn't provide me with a workaround though, as when I import a material from a different project (after first importing the texture assets) it sets its texture settings to the default texture (other settings, like shader, color and shininess, remain though).
I didn't immediately notice the problem, but this is some stuff I did that might have caused it:
I create a material at runtime using this code:
Custom.playerColors[i] = new Material("Shader \"Player Color " + i + "\" {SubShader{Pass{Color(" + playerColors[i].r + " , " + playerColors[i].g + " , " + playerColors[i].b + " , " + playerColors[i].a + ")}}}");
I imported some (projector) shaders from a different project (where materials do work) and I wrote a new one, which also uses the projector matrix and has a fragment program embedded in it (incidentally, it doesn't work yet). Here's the code:
<blockquote>
<p>Shader "Projector/Fog of War" {
Properties { _Transparency
("Transparency", Float) = 0.5
_FogTex ("Cookie", 2D) = "" { TexGen ObjectLinear }
_FalloffTex ("FallOff", 2D) = "" { TexGen ObjectLinear } }
Subshader {
Pass {
ZWrite off
Fog { Color (1, 1, 1) } Color (1 , 1 , 1 , [_Transparency])
ColorMask RGB Offset -1, -1
Blend DstColor OneMinusSrcAlpha</p>
</p><pre><code> CGPROGRAM // Upgrade NOTE: excluded shader from OpenGL ES 2.0
</code></pre>
<p>because it does not contain a surface
program or both vertex and fragment
programs.</p>
<h1>pragma exclude_renderers gles</h1>
<pre><code> #pragma fragment DrawTexture
sampler2D _FogTex;
float4x4 _Projector; float _Transparency;
struct outputWithVariable {
float4 color : COLOR;
float partOfTransp; };
outputWithVariable DrawTexture (float4 color : COLOR, float4
</code></pre>
<p>textureCoord : TEXCOORD0)
{
float3 projectedTextureCoord = mul (_Projector, textureCoord).xyz;
projectedTextureCoord.z = - projectedTextureCoord.z;
float4 fogCoordinate = tex2Dproj (_FogTex,
projectedTextureCoord);
fogCoordinate[3] = 1 - fogCoordinate[3];
outputWithVariable output;
output.color = 2.0 * fogCoordinate * _Transparency *
color;
return output;
}</p>
</p><pre><code> ENDCG
</code></pre>
<p>} } }</p>
</blockquote>
I deleted the line of code that creates a new material and all the materials that were created after the problem, plus all the shaders I imported or created. After that I restarted my project, but the problem is still there.
Does anyone know or have an idea about what's going on? And more importantly, how I can fix this? Any help would be greatly appreciated. Thanks in advance!
So I just noticed this problem too, and I'm guessing it's a new "feature" in the latest version of Unity. I'm curious why they thought that hiding the material properties should be the default without making it obvious how to view them. Very frustrating. Glad there was an easy solution.
This normally happens because you were previously Inspecting an object that had a material. Then you clicked shut that bonus copy of the shared $$anonymous$$aterial down below (which is a perfectly normal thing you might want to do.)
Just like when you click BoxCollider shut, it shuts it for all gameObjects; collapsing sets $$anonymous$$aterial shut for all materials. Also perfectly reasonable, for browsing through other gameObjects. But, a side-effect is all $$anonymous$$aterials are now also collapsed when viewed as Assets.
Answer by yoyo · May 12, 2011 at 08:43 PM
Click on the little circular rendering of the material, just to the left of the shader selection drop-down, and it will toggle the display of the material properties.
don't feel bad ... I spent 20 $$anonymous$$utes of frustrated googling over that one too, just a few weeks ago in fact!
Thanks as well. Just happened to me. Frustrating as crap. Why would they do that? I can't really see a good reason. They need to fix that. Or make it more obvious.