LTDescr.alphaRecursive C# (CSharp) Method

alphaRecursive() private static method

private static alphaRecursive ( Transform transform, float val, bool useRecursion = true ) : void
transform Transform
val float
useRecursion bool
return void
    private static void alphaRecursive( Transform transform, float val, bool useRecursion = true)
    {
        Renderer renderer = transform.gameObject.GetComponent<Renderer>();
        if(renderer!=null){
            foreach(Material mat in renderer.materials){
                if(mat.HasProperty("_Color")){
                    mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
                }else if(mat.HasProperty("_TintColor")){
                    Color col = mat.GetColor ("_TintColor");
                    mat.SetColor("_TintColor", new Color( col.r, col.g, col.b, val));
                }
            }
        }
        if(useRecursion && transform.childCount>0){
            foreach (Transform child in transform) {
                alphaRecursive(child, val);
            }
        }
    }

Same methods

LTDescr::alphaRecursive ( RectTransform rectTransform, float val, int recursiveLevel ) : void
LTDescr