Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Animation Blend Shapes
- //Using C#
- using UnityEngine;
- using System.Collections;
- public class BlendShapeExample : MonoBehaviour
- {
- int blendShapeCount;
- SkinnedMeshRenderer skinnedMeshRenderer;
- Mesh skinnedMesh;
- float blendOne = 0f;
- float blendTwo = 0f;
- float blendSpeed = 1f;
- bool blendOneFinished = false;
- void Awake ()
- {
- skinnedMeshRenderer = GetComponent<SkinnedMeshRenderer> ();
- skinnedMesh = GetComponent<SkinnedMeshRenderer> ().sharedMesh;
- }
- void Start ()
- {
- blendShapeCount = skinnedMesh.blendShapeCount;
- }
- void Update ()
- {
- if (blendShapeCount > 2) {
- if (blendOne < 100f) {
- skinnedMeshRenderer.SetBlendShapeWeight (0, blendOne);
- blendOne += blendSpeed;
- } else {
- blendOneFinished = true;
- }
- if (blendOneFinished == true && blendTwo < 100f) {
- skinnedMeshRenderer.SetBlendShapeWeight (1, blendTwo);
- blendTwo += blendSpeed;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement