示例#1
0
    private void ChangeAlpha(int ID, float alpha)
    {
        if (ID != 1)
        {
            Color TmpColor = Photos[ID].GetComponent <SpriteRenderer>().material.color;
            TmpColor.a = alpha;
            Photos[ID].GetComponent <SpriteRenderer>().material.color = TmpColor;
            foreach (Transform Child in Photos[ID].transform)
            {
                if (Child.name.Equals("hand"))
                {
                    Child.GetComponent <SpriteRenderer>().material.SetFloat("_Alpha", alpha);
                }
                else
                {
                    TmpColor   = Child.GetComponent <SpriteRenderer>().material.color;
                    TmpColor.a = alpha;
                    Child.GetComponent <SpriteRenderer>().material.color = TmpColor;

                    foreach (Transform Son in Child)
                    {
                        TmpColor   = Son.GetComponent <SpriteRenderer>().material.color;
                        TmpColor.a = alpha;
                        Son.GetComponent <SpriteRenderer>().material.color = TmpColor;
                    }
                }
            }
        }
        else
        {
            Photos[ID].GetComponent <SpriteRenderer>().material.SetFloat("_Alpha", alpha);
            foreach (Transform Child in Photos[ID].transform)
            {
                if (Child.name.Equals("hand"))
                {
                    Child.GetComponent <SpriteRenderer>().material.SetFloat("_Alpha", alpha);
                }
                else
                {
                    Color TmpColor = Child.GetComponent <SpriteRenderer>().material.color;
                    TmpColor.a = alpha;
                    Child.GetComponent <SpriteRenderer>().material.color = TmpColor;

                    foreach (Transform Son in Child)
                    {
                        TmpColor   = Son.GetComponent <SpriteRenderer>().material.color;
                        TmpColor.a = alpha;
                        Son.GetComponent <SpriteRenderer>().material.color = TmpColor;
                    }
                }
            }
        }
    }