Unity3d 如何使用混合变形名称而不是索引控制脚本中的每个混合变形值?

Unity3d 如何使用混合变形名称而不是索引控制脚本中的每个混合变形值?,unity3d,Unity3d,例如,我想随机将“口腔混合变形”(mouth blend shape)值从0更改为23,以便在显示文本时模拟说话。这不是真的,嘴唇会像文本一样移动,只是在文本显示时模拟说话,所以我想在0到23之间或多或少随机设置一些值 我试过了,但没用,没用。它根本不会改变鼠标混合形状的值 脚本通过混合图形附着到对象 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Blen

例如,我想随机将“口腔混合变形”(mouth blend shape)值从0更改为23,以便在显示文本时模拟说话。这不是真的,嘴唇会像文本一样移动,只是在文本显示时模拟说话,所以我想在0到23之间或多或少随机设置一些值

我试过了,但没用,没用。它根本不会改变鼠标混合形状的值

脚本通过混合图形附着到对象

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BlendShapesController : MonoBehaviour
{
    private SkinnedMeshRenderer bodySkinnedMeshRenderer;

    // Start is called before the first frame update
    void Start()
    {
        bodySkinnedMeshRenderer = GetComponent<SkinnedMeshRenderer>();
    }

    // Update is called once per frame
    void Update()
    {
        int rand = Random.Range(0, 23);
        bodySkinnedMeshRenderer.SetBlendShapeWeight(0, rand);
    }
}
使用系统集合;
使用System.Collections.Generic;
使用UnityEngine;
公共类混合形状控制器:MonoBehavior
{
私有SkinnedMeshRenderer bodySkinnedMeshRenderer;
//在第一帧更新之前调用Start
void Start()
{
bodySkinnedMeshRenderer=GetComponent();
}
//每帧调用一次更新
无效更新()
{
int rand=随机范围(0,23);
bodySkinnedMeshRenderer.SetblendShapeLight(0,兰德);
}
}

解决方案:由于带有SkinnedMeshRenderer的对象是子对象,而父对象有一个Animator组件,因此我必须更改父对象上的Animator组件设置,以设置物理动画,并始终设置动画

<>我用索引而不是名字,但是它在工作,所以我将把它当作一个解决方案,因为它在工作。