Unity3D动作资源(AnimatinClip)优化
能做到去掉Scale曲线,降低浮点精度
using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor; public static class RemoveAnimationClipScale
{ [MenuItem("Tools/Animation/Remove Animation Clip Scale")]
public static void RemoveAnimationClipScaleMenu()
{ int i = 0;
int total = 0; try
{
EditorUtility.DisplayProgressBar("Remove Animation Clip Scale", "Collecting Animation Clip", 0);
var gos = EnumAssets.EnumInCurrentSelection<UnityEngine.AnimationClip>();
total = gos.Count();
if (total > 0)
{
foreach (var go in gos)
{
EditorUtility.DisplayProgressBar("Remove Animation Clip Scale", go.name, i * 1.0f / total);
OnPostprocessAnimation(go);
i++;
}
}
}
catch (Exception)
{ }
finally
{
EditorUtility.ClearProgressBar();
AssetDatabase.Refresh();
AssetDatabase.SaveAssets();
Debug.Log("Tools/Animation/Optimize Animation: total[" + total + "]");
} } static void OnPostprocessAnimation(AnimationClip theAnimation)
{
try
{
//去除scale曲线
foreach (EditorCurveBinding theCurveBinding in AnimationUtility.GetCurveBindings(theAnimation))
{
string name = theCurveBinding.propertyName.ToLower();
if (name.Contains("scale"))
{
AnimationUtility.SetEditorCurve(theAnimation, theCurveBinding, null);
}
} //浮点数精度压缩到f3
AnimationClipCurveData[] curves = null;
curves = AnimationUtility.GetAllCurves(theAnimation);
Keyframe key;
Keyframe[] keyFrames;
for (int ii = 0; ii < curves.Length; ++ii)
{
AnimationClipCurveData curveDate = curves[ii];
if (curveDate.curve == null || curveDate.curve.keys == null)
{
//Debug.LogWarning(string.Format("AnimationClipCurveData {0} don't have curve; Animation name {1} ", curveDate, animationPath));
continue;
}
keyFrames = curveDate.curve.keys;
for (int i = 0; i < keyFrames.Length; i++)
{
key = keyFrames[i];
key.value = float.Parse(key.value.ToString("f3"));
key.inTangent = float.Parse(key.inTangent.ToString("f3"));
key.outTangent = float.Parse(key.outTangent.ToString("f3"));
keyFrames[i] = key;
}
curveDate.curve.keys = keyFrames;
theAnimation.SetCurve(curveDate.path, curveDate.type, curveDate.propertyName, curveDate.curve);
}
}
catch (Exception e)
{
Debug.LogError(string.Format("CompressAnimationClip Failed !!! animationPath : {0} error: {1}", theAnimation.name, e));
}
}
}
Unity3D动作资源(AnimatinClip)优化的更多相关文章
- Unity 打包总结和资源的优化和处理
1. Texture,都去掉alpha通道,作为背景展示的图片,基本都没有透明要求,有特殊要求的则放到atlas里面 a. Loading图这类需要比较精细的,则把图片设置为Automatic Tru ...
- Unity3d Web3d资源的动态加载
Unity3d Web3d资源的动态加载 @灰太龙 参考了宣雨松的博客,原文出处http://www.xuanyusong.com/archives/2405,如果涉及到侵权,请通知我! Unity3 ...
- Unity3d代码及效率优化总结
1.PC平台的话保持场景中显示的顶点数少于200K~3M,移动设备的话少于10W,一切取决于你的目标GPU与CPU. 2.如果你用U3D自带的SHADER,在表现不差的情况下选择Mobile或Unli ...
- Intel64及IA-32架构优化指南第8章多核与超线程技术——8.9 其它共享资源的优化
8.9 其它共享资源的优化 在多线程应用中的资源优化依赖于处理器拓扑层级内相关联的Cache拓扑以及执行资源.在第7章中讨论了处理器拓扑以及标识处理器拓扑的一种软件算法. 在带有共享总线的平台中,总线 ...
- Unity3D移动端内存优化(NGUI方面)
Unity3D引擎技术交流QQ群:[21568554] 做3d移动端内存一直是人们头疼的问题,载入的资源释放了,还有其它的须要释放.比方ngui释放,事实上主要是NGUI的Texture和Spr ...
- Unity3D 的大场景内存优化
我们公司的一个 MMORPG 项目最近在内存方面碰到了红线,昨天开会讨论了一下.我提出了一个改进方案,写篇 blog 记录一下. 问题是这样的.在当下的手机及平板硬件设备条件下,操作系统留给应用的可用 ...
- 跟我从零基础学习Unity3D开发--资源打包篇(AssetBundle)
好久没更新了,一直在加班敢项目进度.这里和关注我的博客的童鞋表示一下歉意!这里有我录的Unity3D从零开始的视频教程大家可以关注一下:http://www.imooc.com/view/555 视 ...
- unity3d 加密资源并缓存加载
原地址:http://www.cnblogs.com/88999660/archive/2013/04/10/3011912.html 首先要鄙视下unity3d的文档编写人员极度不负责任,到发帖为止 ...
- 详谈 Unity3D AssetBundle 资源加载,结合实际项目开发实例
第一次搞资源更新方面,这里只说更新,加载,AssetBundle资源加载,谈谈自己的理解,以及自己在项目中遇到的那些神坑,现在回想一下,真的是自己跪着过来的,说多了,都是泪. 我这边是安卓AssetB ...
随机推荐
- spark shell学习笔记
http://homepage.cs.latrobe.edu.au/zhe/ZhenHeSparkRDDAPIExamples.html
- linux 系统安装mysql (rpm)
其实按照本文安装成功,但是启动依然有问题:最好参考链接配置. http://blog.csdn.net/xiaoxiaoxuewen/article/details/7550107 我用的是ubunt ...
- GridView通过RowDataBound事件获取字段值、数据源列值
如果数据源有某一列,而在绑定到GridView时不显示该列,编程时要用到该列的值可以用以下方法: protected void GridView1_RowDataBound(object sender ...
- GridView如何将分页数据全部导出为EXCEL?
GRIDVIEW分页状态下将全部数据导出 protected void Button2_Click(object sender, EventArgs e)//按button2将gridview将数据导 ...
- Android Studio INSTALL_FAILED_UID_CHANGED的解决办法
使用Android Studio开发Android应用,把Android应用调试安装在手机上时,出现了安装失败的提示:INSTALL_FAILED_UID_CHANGED. 上网找了很多资料: 1.说 ...
- input checkbox复选框点击获取当前选中状态jquery
function checkAll(id) { //用is判断 // let checkStatus=$(id).is(':checked'); // console.log(checkStatus) ...
- Java虚拟机(JVM)你只要看这一篇就够了!
1. Java 内存区域与内存溢出异常 1.1 运行时数据区域 根据<Java 虚拟机规范(Java SE 7 版)>规定,Java 虚拟机所管理的内存如下图所示. 1.1.1 程序计数器 ...
- ubuntu14.04 允许root用ssh登录
重启ssh service ssh restart 查看ssh是否已安装 ssh进程 ps -e | grep ssh ssh占用端口 lsof -i:22 ssh服务已启动,但是用root账号无法连 ...
- jquery.fileupload插件 ie9下不支持上传
根据https://github.com/blueimp/jQuery-File-Upload/wiki/Browser-support The following browsers support ...
- ios学习之UIWebView网页视图
转载于爱德凡的百度空间,地址:http://hi.baidu.com/aidfan/item/34a720866b33cbcdef083d37 UIWebView 使用详解 一.UIWebView加载 ...