Esempio n. 1
0
        private void PutOn(GameObject go, int type, bool isSkinned, bool needMapping)
        {
            if (null == go)
            {
                return;
            }

            if (isSkinned)
            {
                go.transform.SetParent(_characterGameObject.transform, false);
                go.transform.localPosition = Vector3.zero;
                go.transform.localRotation = Quaternion.identity;
                //                go.transform.localScale = Vector3.one;

                var allWardrobeBones = go.GetComponentsInChildren <Transform>();
                _allAvatarBones[(Wardrobe)type] = allWardrobeBones;

                foreach (var renderer in go.GetComponentsInChildren <SkinnedMeshRenderer>())
                {
                    // 映射装扮与人物骨骼
                    if (needMapping)
                    {
                        var wardrobeBones = GetBonesOfTheSameName(renderer.bones, allWardrobeBones);
                        MappingBones(wardrobeBones, type);
                    }
                    renderer.bones    = GetBonesOfTheSameName(renderer.bones, _allBonesDictionary);
                    renderer.rootBone = GetBoneOfTheSameName(renderer.rootBone, _allBonesDictionary);
                }
            }
            else
            {
                _mount.MountWardrobe(go, _characterGameObject);
            }
            Logger.InfoFormat("CharacterLog-- SureAddWardrobe:  {0}", go.name);
        }