Exemple #1
0
        /// <summary>还原金身状态,由回收池调用</summary>
        public void ResetModel()
        {
            if (MaterialList == null)
            {
                return;
            }
            int            index          = 0;
            Transform      body           = Body();
            Animator       animator       = body.GetComponent <Animator>();
            MoveController moveController = body.GetComponent <MoveController>();

            Renderer[] renderers = body.GetComponentsInChildren <SkinnedMeshRenderer>();
            for (int i = 0; i < renderers.Length; i++)
            {
                Renderer   render    = renderers[i];
                Material[] materials = render.materials;
                Material   goldMat   = materials[0];
                for (int j = 0; j < materials.Length; j++)
                {
                    Material GoldMaterial = MaterialList[index];
                    index++;
                    materials[j] = GoldMaterial;
                }
                render.materials = materials;
            }

            MaterialList     = null;
            animator.enabled = true;
            animator.Play("Idle");

            ParticleSystem[] ps = moveController.GetComponentsInChildren <ParticleSystem>();

            for (int i = 0; i < ps.Length; i++)
            {
                ps[i].Play();
            }
        }