Search Unity

shader for translate, rotate, scale affordances

Discussion in 'Shaders' started by Jagwire, Dec 19, 2014.

  1. Jagwire

    Jagwire

    Joined:
    Dec 5, 2013
    Posts:
    59
    I like the transform affordances (translate axes, rotation circles, scale axes) shader for a couple reasons:
    1. They're lit.
    2. They're rendered on top of the objects they're being applied toward.
    3. They stay the same absolute size across editor camera pans and so forth.
    Is this shader available? What are the clutch aspects of such a shader if one wanted to recreate it?

    thanks!
     
  2. Jagwire

    Jagwire

    Joined:
    Dec 5, 2013
    Posts:
    59
    I was able to piece together the following surface shader which demonstrates the desired behavior. Critiques welcome!

    Code (CSharp):
    1. Shader "Custom/Handles_Shader" {
    2.     Properties {
    3.         _MainColor ("Main Color", Color) = (1, 1, 1, 1)
    4.     }
    5.     SubShader {
    6.         Tags { "RenderType"="Transparent" "Queue"="Overlay" }
    7.         LOD 200
    8.         ZTest Always
    9.  
    10.         CGPROGRAM
    11.         #pragma surface surf Lambert
    12.  
    13.         struct Input {
    14.             float4 color : COLOR;
    15.         };
    16.         float4 _MainColor;
    17.         void surf (Input IN, inout SurfaceOutput o) {
    18.             o.Albedo = _MainColor.rgb;
    19.         }
    20.         ENDCG
    21.     }
    22.     FallBack "Diffuse"
    23. }