U3D 复制曲线
发布日期:2021-06-30 14:56:45
浏览次数:4
分类:技术文章
本文共 1431 字,大约阅读时间需要 4 分钟。
using UnityEngine;using UnityEditor;[CustomPropertyDrawer(typeof(AnimationCurve))]public class CurvePropertyDrawer: PropertyDrawer { private const int _buttonWidth = 12; private static Keyframe[] _buffer; private static WrapMode _preWrapMode; private static WrapMode _postWrapMode; public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) { prop.animationCurveValue = EditorGUI.CurveField( new Rect(pos.x, pos.y, pos.width - _buttonWidth * 2, pos.height), label, prop.animationCurveValue ); // Copy if ( GUI.Button( new Rect(pos.x + pos.width - _buttonWidth * 2, pos.y, _buttonWidth, pos.height), "" ) ) { _buffer = prop.animationCurveValue.keys; _preWrapMode = prop.animationCurveValue.preWrapMode; _postWrapMode = prop.animationCurveValue.postWrapMode; } GUI.Label( new Rect(pos.x + pos.width - _buttonWidth * 2, pos.y, _buttonWidth, pos.height), "C" ); // Paste if (_buffer == null) return; if ( GUI.Button( new Rect(pos.x + pos.width - _buttonWidth, pos.y, _buttonWidth, pos.height), "" ) ) { AnimationCurve newAnimationCurve = new AnimationCurve(_buffer); newAnimationCurve.preWrapMode = _preWrapMode; newAnimationCurve.postWrapMode = _postWrapMode; prop.animationCurveValue = newAnimationCurve; } GUI.Label( new Rect(pos.x + pos.width - _buttonWidth, pos.y, _buttonWidth, pos.height), "P" ); } // OnGUI() } // class CurvePropertyDrawer
转载地址:https://jerryjin.blog.csdn.net/article/details/83341907 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
路过,博主的博客真漂亮。。
[***.116.15.85]2024年04月13日 01时11分45秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
小程序实现sku商品规格
2019-05-01
js对象的属性用变量值代替
2019-05-01
小程序图片转Base64,方法总结
2019-05-01
element中路由跳转以后激活当前菜单高亮
2019-05-01
VUE中同级页面传参的方式
2019-05-01
微信小程序setData复杂数组的更新、删除、添加、拼接
2019-05-01
has been blocked by CORS policy: Response to preflight request doesn‘t pass access control check 报错
2019-05-01
微信小程序 分享的图片使用canvas生成
2019-05-01
JS算法之累加
2019-05-01
从四川电视台播放事故论AI智能审核的重要性
2019-05-01
List集合排序Comparable与Comparator实现
2019-05-01
你为什么要写这样的代码?你知不知道填这个坑有多难
2019-05-01
查看生产环境日记常用的几个linux命令
2019-05-01
spring+quartz.2.3.0数据库持久化实现
2019-05-01
Malformed \uxxxx encoding.异常
2019-05-01
使用aspose.words 18.6实现pdf文档转换
2019-05-01
Java 生成文字图片
2019-05-01