public void Initialize() { if (umaData != null && umaData.skeleton != null) { expressionSet = umaData.umaRecipe.raceData.expressionSet; if (umaData.animator != null) { Transform jaw = umaData.animator.GetBoneTransform(HumanBodyBones.Jaw); if (jaw != null) { jawHash = UMAUtils.StringToHash(jaw.name); } Transform neck = umaData.animator.GetBoneTransform(HumanBodyBones.Neck); if (neck != null) { neckHash = UMAUtils.StringToHash(neck.name); } Transform head = umaData.animator.GetBoneTransform(HumanBodyBones.Head); if (head != null) { headHash = UMAUtils.StringToHash(head.name); } } if (expressionSet != null) { values = new float[expressionSet.posePairs.Length]; initialized = true; } } }
static void CreatMan() { ExpressModel model = new ExpressModel_Male(); model.Creat(); return; string name = "male"; GameObject g = GameObject.Find(name); if (g) { GameObject.DestroyImmediate(g); } string path = "Assets/Tmp/FBX/Human_Male/Human_Male.fbx"; Object o = AssetDatabase.LoadAssetAtPath(path, typeof(Object)); GameObject go = GameObject.Instantiate(o) as GameObject; string m1p = "Assets/Tmp/Expression/mat/male.mat"; string m2p = "Assets/Tmp/Expression/mat/male-face.mat"; Material m1 = AssetDatabase.LoadAssetAtPath(m1p, typeof(Object)) as Material; Material m2 = AssetDatabase.LoadAssetAtPath(m2p, typeof(Object)) as Material; SkinnedMeshRenderer[] smrs = go.GetComponentsInChildren <SkinnedMeshRenderer>(); for (int i = 0; i < smrs.Length; i++) { if (smrs[i].gameObject.name.EndsWith("_Face")) { smrs[i].sharedMaterial = m2; } else { smrs[i].sharedMaterial = m1; } } Animator an = go.GetComponent <Animator>(); if (an) { GameObject.DestroyImmediate(an); } Transform skeletonRoot = go.transform.FindChild("UMA_Male_Rig"); string expressionPlayerPath = "Assets/Character/UMA/Content/UMA/Humanoid/Expressions/Expression Sets/Male_Expression_Set.asset"; UMAExpressionSet expressionPlayer = AssetDatabase.LoadAssetAtPath <Object>(expressionPlayerPath) as UMAExpressionSet; go.AddComponent <Animation>(); ExpressionPlayer ep = go.AddComponent <ExpressionPlayer>(); EditModeExpressionPreview emp = go.AddComponent <EditModeExpressionPreview>(); emp.expressionPlayer = ep; emp.expressionSet = expressionPlayer; emp.skeletonRoot = skeletonRoot; go.name = name; }
public void OnUMACreated(UMAData data) { expressionPlayer = data.gameObject.GetComponent <UMAExpressionPlayer>(); if (expressionPlayer == null) { expressionPlayer = data.gameObject.AddComponent <UMAExpressionPlayer>(); } UMAExpressionSet expressionSet = data.umaRecipe.raceData.expressionSet; expressionPlayer.expressionSet = expressionSet; expressionPlayer.umaData = data; expressionPlayer.Initialize(); }
//practical guide to UMA part 15 intercepting uma events https://youtu.be/_k-SZRCvgIk?t=4m17s void CharacterCreatedCallback(UMAData umaData) { //Debug.Log("UMA_Created"); GrabStaff(); // A Practical Guide To UMA - Part 17 - Using the Expression Player https://youtu.be/nJI-kUYYuWE UMAExpressionSet expressionSet = umaData.umaRecipe.raceData.expressionSet; expressionPlayer = umaData.gameObject.AddComponent <UMAExpressionPlayer>(); expressionPlayer.expressionSet = expressionSet; expressionPlayer.umaData = umaData; expressionPlayer.Initialize(); // automated expressions to look life like expressionPlayer.enableBlinking = true; expressionPlayer.enableSaccades = true; }
public void Creat() { IObjectBase iob = new ObjectBase(fbx); Object o = iob.Load(); go = GameObject.Instantiate(o) as GameObject; go.name = name; SkinnedMeshRenderer[] smrs = go.GetComponentsInChildren <SkinnedMeshRenderer>(); for (int i = 0; i < smrs.Length; i++) { if (smrs[i].gameObject.name.EndsWith("_Face")) { smrs[i].sharedMaterial = faceMat; } else { smrs[i].sharedMaterial = bodyMat; } } Animator an = go.GetComponent <Animator>(); if (an) { GameObject.DestroyImmediate(an); } Transform skeletonRoot = go.transform.FindChild(rig); IObjectBase set = new ObjectBase(expression_Set); UMAExpressionSet expressionPlayer = set.Load <UMAExpressionSet>(); anim = go.AddComponent <Animation>(); ep = go.AddComponent <ExpressionPlayer>(); EditModeExpressionPreview emp = go.AddComponent <EditModeExpressionPreview>(); emp.expressionPlayer = ep; emp.expressionSet = expressionPlayer; emp.skeletonRoot = skeletonRoot; go.name = name; Selection.activeGameObject = go;//selected }