c# - 在 Animator 中使用 Unity 事件切换网格渲染器
问题描述
大家好,我对统一很陌生,我正在尝试制作一个动画,其中预制件中的一些网格仅在动画的中途出现。
我已经在 animator 中的所需时间添加了一个事件,但我无法确切知道我需要执行哪些代码来打开网格渲染器。
到目前为止,我有这个:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class toggleMesh : MonoBehaviour
{
public Renderer rend;
// Start is called before the first frame update
void Start()
{
rend = GetComponent<Renderer>();
rend.enabled = false;
}
// Update is called once per frame
public void toggleMeshR()
{
rend.enabled = true;
}
}
对此的任何帮助将不胜感激
解决方案
如果您有您所说的动画,请在您希望调用toggleMeshR()的帧(时间)上放置一个动画事件。
当您右键单击动画时间轴时,您可以创建动画事件。更多信息:https ://docs.unity3d.com/Manual/script-AnimationWindowEvent.html
推荐阅读
- tkinter - 如何在 tkinter 列表框中正确对齐文本?
- javascript - 如何从 React 中的另一个文件调用对话框
- python - Gekko,将动态参数传递给 pwl
- flutter - Flutter Firestore - 没有为“Stream”类型定义方法“documents”
- reactjs - 在 react-native 动画中使用计算变量
- python - AttributeError:“function”对象没有属性“tableId”。Apache Beam 数据流运行器
- node.js - 节点 TypeScript 导入/导出机制
- excel - 如何使用 vba 在 excel 中仅将一个工作表保存为不同的工作簿?
- azure - 错误“指定的应用程序包不存在。” 在从 azure cli 检查是否存在 azure 批处理应用程序包时?
- r - 手动制作随机森林模型不会给出相同的结果