本项目以Morgan为中心,处理这个角色需要将 VFX Graph 的功能发挥到极致。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

46 行
1.2 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[ExecuteAlways]
public class ConnectMorganMorph : MonoBehaviour
{
public bool useBlendValue;
public float blendValue;
public GameObject[] targetShapes;
int blendShapeCount;
GameObject sourceObject;
SkinnedMeshRenderer skinnedMeshRenderer;
Mesh skinnedMesh;
void Start()
{
}
void Update()
{
for (int i = 0; i < targetShapes.Length; i++)
{
if (targetShapes[i] != null)
{
skinnedMeshRenderer = targetShapes[i].GetComponent<SkinnedMeshRenderer>();
skinnedMesh = targetShapes[i].GetComponent<SkinnedMeshRenderer>().sharedMesh;
blendShapeCount = skinnedMesh.blendShapeCount;
for (int k = 0; k < blendShapeCount; k++)
{
if (useBlendValue == true)
{
skinnedMeshRenderer.SetBlendShapeWeight(k, blendValue);
}
else
{
skinnedMeshRenderer.SetBlendShapeWeight(k, -transform.localPosition.x * 100f);
}
}
}
}
}
}