Esempio n. 1
0
    void CreateFragments()
    {
        if (fragments.Length > 0)
        {
            GameObject fragmentOriginal = (GameObject)Instantiate(primitiveQuad);
            fragmentOriginal.transform.localScale = transform.localScale;

            foreach (Fragment frag in fragments)
            {
                Vector3 newPosition = transform.position;
                newPosition.z = 10.1f;

                frag.fragmentObject = (GameObject)Instantiate(fragmentOriginal, newPosition, transform.rotation);

                MeshRenderer renderer = frag.fragmentObject.GetComponent <MeshRenderer>();
                renderer.material = frag.material;

                FadeOut fade = frag.fragmentObject.AddComponent <FadeOut>();
                fade.SetTimes(4, 5);
            }

            Destroy(fragmentOriginal);
        }
    }