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 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:U3D自定义
下一篇:U3D Animator 组件控制动画的播放暂停,动态添加帧事件

发表评论

最新留言

路过,博主的博客真漂亮。。
[***.116.15.85]2024年04月13日 01时11分45秒