Shader that will change only transparent part of texture

I set a color to my object with:

renderer.material.color = Color.yellow;

Now what I want that only part of the object which has transparent texture will be yellow, but that other part of the texture will not be affected. Which shader should I use, or is there some other trick for this?

You need to create a new shader. We will define the word “transparency”, as (alpha-channel < value Range from 0 to 1). It will look approximately so:

 Shader "Custom/myChangeColorAlpha" {
  Properties {
   _AlphaColor ("Alpha Color", Color) = (1.0, 1.0, 1.0, 1.0)
   _MainTex ("Texture", 2D) = "white" {}
   _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
  }

  SubShader {
   Tags { "RenderType" = "Opaque" }
   CGPROGRAM
   #pragma surface surf Lambert
   struct Input {
    float2 uv_MainTex;
   };

   sampler2D _MainTex;
   float4 _AlphaColor;
   float _Cutoff;

   void surf (Input IN, inout SurfaceOutput o) {
    float4 col = tex2D (_MainTex, IN.uv_MainTex);
    o.Albedo = col.rgb;
    if (col.a < _Cutoff) {
     o.Albedo = _AlphaColor.rgb;
    }
    o.Alpha = col.a;
   }
   ENDCG
  } 
  Fallback "Diffuse"
 }

And it is necessary to change color in a material so:

 renderer.material.SetColor ("_AlphaColor", Color.yellow);

I hope that it will help you.