Unity Animation采样和自定义属性
来源:互联网 发布:淘宝店铺类目修改2016 编辑:程序博客网 时间:2024/05/21 01:29
1、了解Animation的采样函数Sample怎么使用。
2、了解自定义属性面板
动画的采样可用于自定义编辑器等工具,也可以自己实现一套动画系统
首先看一下自定义属性面板,网上都有相关代码和教程,在这里粘贴一处网上的代码,如果冒犯,望海涵~
using UnityEngine;using System.Collections;public class MyRangeAttribute : PropertyAttribute{ public float min; public float max; public string label; public MyRangeAttribute( float min, float max, string label = "") { this.min = min; this.max = max; this.label = label; }}
using UnityEngine;using UnityEditor;using System.Collections;//该代码放在Editor目录下[CustomPropertyDrawer(typeof(MyRangeAttribute))]public class MyRangeAttributeDrawer : PropertyDrawer { public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { MyRangeAttribute range = this.attribute as MyRangeAttribute; if( property.propertyType == SerializedPropertyType.Float ) { if (range.label != string.Empty) { label.text = range.label; } EditorGUI.Slider(position, property, range.min, range.max, label); } else if( property.propertyType == SerializedPropertyType.Integer ) { if( range.label != string.Empty ) { label.text = range.label; } EditorGUI.IntSlider(position, property, (int)range.min, (int)range.max, label); } }}
using UnityEngine;using System.Collections;[ExecuteInEditMode]public class AnimationTest : MonoBehaviour { public Animation anim; [MyRangeAttribute(0f,1f,"动画采样")] public float curValue = 0f; float deltaTime = 0f; float lastFrameTime = 0f; float progressTime = 0f; string clipName = "run";void Start () { anim.enabled = false; AnimationState state = anim[clipName]; state.enabled = true; state.weight = 1; state.normalizedTime = 0; anim.Sample(); state.enabled = false;}// Update is called once per framevoid Update () { deltaTime = Time.realtimeSinceStartup; progressTime += deltaTime - lastFrameTime; Example(); lastFrameTime = deltaTime;} void Example() { AnimationState animState = anim[clipName]; animState.enabled = true; animState.speed = 1f; animState.weight = 1; if (curValue > 1f) { curValue = 0f; } animState.normalizedTime = curValue; anim.Sample(); animState.enabled = false; }}这样就可以自由操作动画的播放了
0 0
- Unity Animation采样和自定义属性
- Unity Animator采样和Animation采样
- jmeter之HTTP取样器、Webserivce采样器、Debug Sampler、Cookie、header、授权、jdbc连接、用户自定义属性和变量
- unity-Animation
- Unity Animation
- Unity Animation
- Unity Animation
- AnimationMode采样Animator或Animation
- CSS3 动画 Transitions, Transforms和Animation属性
- 【html5和css3】animation属性整理
- CSS3 Transform、Transition和Animation属性总结
- 经典属性玩转transition和animation
- Unity/Animation -- 创建Animation Clip
- Unity/Animation -- 调节Animation Curves
- Unity/Animation -- 创建Animation Clip
- 自定义Animation
- 自定义控件和自定义属性
- 过采样和欠采样
- 欢迎使用CSDN-markdown编辑器
- VBox下的CentOS挂载共享文件夹
- 免费的优秀工具推荐!!
- Android开发——四大组件之BroadcastReceiver概念
- zk--preface(57)
- Unity Animation采样和自定义属性
- Tomcat的Server.xml虚拟主机和虚拟目录的配置
- 2016-12-22工作日志
- ISD9160学习笔记05_ISD9160语音识别代码分析
- 学会封装自己的class类:
- angular自定义指令templateUrl
- c# 数字转大写中文
- 功角自平衡 摘自张幸浩的《永磁同步电机的低成本控制系统研究》
- Android开发——四大组件BroadcastReceiver实例广播事件的拦截转发