Example #1
0
        public void LoadCharacter()
        {
            LoadCharacterSkin();

            //  Create eyes.
            if (eyes != null)
            {
                eyesObject = Instantiate(eyes, GetTransform(HumanBodyBones.Head)) as CharacterSkinObject;
            }
        }
Example #2
0
        private CharacterSkinObject CreateSkinObject(string skinObjectName, Transform parent = null)
        {
            GameObject go = new GameObject(skinObjectName, typeof(MeshFilter), typeof(MeshRenderer), typeof(CharacterSkinObject));

            go.transform.parent           = parent == null ? transform : parent;
            go.transform.localPosition    = Vector3.zero;
            go.transform.localEulerAngles = Vector3.zero;

            CharacterSkinObject skinObject = go.GetComponent <CharacterSkinObject>();

            //skinObjects.Add(skinObject);
            return(skinObject);
        }
Example #3
0
        private void UpdateMesh(CharacterSkinObject skinObject, Mesh mesh, Material material)
        {
            MeshFilter   meshFilter   = skinObject.GetComponent <MeshFilter>();
            MeshRenderer meshRenderer = skinObject.GetComponent <MeshRenderer>();

            if (mesh != null)
            {
                meshFilter.mesh = mesh;
                skinObject.gameObject.SetActive(true);
                meshRenderer.material = material;
            }
            else
            {
                meshFilter.mesh = null;
                skinObject.gameObject.SetActive(false);
                meshRenderer.material = null;
            }
        }
Example #4
0
        private void Initialize()
        {
            if (GetComponent <Animator>() == null)
            {
                if (GetComponentInParent <Animator>() == null)
                {
                    return;
                }
            }

            if (hairObject == null)
            {
                hairObject = CreateSkinObject(SkinIDs.Hair, GetTransform(HumanBodyBones.Head));
            }
            if (hatHairObject == null)
            {
                hatHairObject = CreateSkinObject(SkinIDs.HatHair, GetTransform(HumanBodyBones.Head));
            }
        }