void Update()
        {
            if (expressionSet == null)
            {
                return;
            }
            if (skeletonRoot == null)
            {
                return;
            }
            if (expressionPlayer == null)
            {
                expressionPlayer = gameObject.GetComponent <ExpressionPlayer>();
                if (expressionPlayer == null)
                {
                    Debug.LogWarning("Couldn't find expression player to preview!");
                    return;
                }
            }

            if (skeleton == null)
            {
                skeleton = new UMASkeleton(skeletonRoot);
            }

            expressionSet.RestoreBones(skeleton);

            float[] values = expressionPlayer.Values;

            for (int i = 0; i < values.Length; i++)
            {
                float weight = values[i];

                UMABonePose pose = null;
                if (weight > 0)
                {
                    pose = expressionSet.posePairs[i].primary;
                }
                else
                {
                    weight = -weight;
                    pose   = expressionSet.posePairs[i].inverse;
                }
                if (pose == null)
                {
                    continue;
                }

                pose.ApplyPose(skeleton, weight);
            }
        }
Пример #2
0
		void Update()
		{
			if (expressionSet == null) return;
			if (skeletonRoot == null) return;
			if (expressionPlayer == null)
			{
				expressionPlayer = gameObject.GetComponent<ExpressionPlayer>();
				if (expressionPlayer == null)
				{
					Debug.LogWarning("Couldn't find expression player to preview!");
					return;
				}
			}

			if (skeleton == null)
			{
				skeleton = new UMASkeleton(skeletonRoot);
			}

			expressionSet.ResetBones(skeleton);

			float[] values = expressionPlayer.Values;

			for (int i = 0; i < values.Length; i++)
			{
				float weight = values[i];

				UMABonePose pose = null;
				if (weight > 0)
				{
					pose = expressionSet.posePairs[i].primary;
				}
				else
				{
					weight = -weight;
					pose = expressionSet.posePairs[i].inverse;
				}
				if (pose == null) continue;

				pose.ApplyPose(skeleton, weight);
			}
		}
Пример #3
0
        public override void OnInspectorGUI()
        {
            GUILayout.BeginVertical();

            if (expressionSet.posePairs.Length != UMAExpressionPlayer.PoseCount)
            {
                Debug.LogWarning("Expression Set out of sync with Expression Poses!");
                System.Array.Resize <UMAExpressionSet.PosePair>(ref expressionSet.posePairs, UMAExpressionPlayer.PoseCount);
            }

            for (int i = 0; i < UMAExpressionPlayer.PoseCount; i++)
            {
                string primary = ExpressionPlayer.PrimaryPoseName(i);
                string inverse = ExpressionPlayer.InversePoseName(i);
                if (expressionSet.posePairs[i] == null)
                {
                    expressionSet.posePairs[i] = new UMAExpressionSet.PosePair();
                }
                if (primary != null)
                {
                    EditorGUILayout.LabelField(primary);
                    expressionSet.posePairs[i].primary = EditorGUILayout.ObjectField(expressionSet.posePairs[i].primary, typeof(UMABonePose), false) as UMABonePose;
                }
                if (inverse != null)
                {
                    EditorGUILayout.LabelField(inverse);
                    expressionSet.posePairs[i].inverse = EditorGUILayout.ObjectField(expressionSet.posePairs[i].inverse, typeof(UMABonePose), false) as UMABonePose;
                }
                EditorGUILayout.Space();
            }

            GUILayout.EndVertical();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
                AssetDatabase.SaveAssets();
            }
        }
Пример #4
0
		public void OnEnable()
		{
			player = target as ExpressionPlayer;
		}
 public void OnEnable()
 {
     player = target as ExpressionPlayer;
 }