How to get a surface shader to use the ambient light?

It’s my understanding that surface shaders should use the ambient light color from Edit->Render
Settings unless you explicitly use the “noambient” keyword. However, I’ve run into the following problem:

  • I set up an empty scene with 2 cubes in front of the camera. No lights.
  • I assign a different material to each cube. Left cube’s material uses the standard Unity diffuse shader. No texture.
  • I use a basic custom shader for the right cube’s material that simply outputs a color. I set that color as white.
  • I ramp the ambient color to pure red. As expected, the left cube paints in red, since there are no other lights. The right cube using my custom shader paints in black.

This is my shader:

Shader "Custom/TestShader" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
	}
	SubShader {
		Tags { "RenderType"="Opaque" }
		LOD 200
		
		CGPROGRAM
		#pragma surface surf Lambert

		sampler2D _MainTex;
		fixed4 _Color;

		struct Input {
			float2 uv_MainTex;
		};

		void surf (Input IN, inout SurfaceOutput o) {
			o.Albedo = _Color.rgb;
			o.Alpha = _Color.a;
		}
		ENDCG
	} 
	FallBack "Diffuse"
}

Is there something else I’m missing?

There’s nothing wrong with that shader. I can’t replicate your results. I made a totally empty scene with the same setup you just described, and got this (notice the camera preview):

I copy-pasted the shader you posted as is and put it on a new material and stuck that on the box to the right. The one on the left uses standard diffuse, no changes, no texture. No lights.

There’s gotta be something else in your project that interferes with the output. Try to do it in a new project and test?