本文整理汇总了C#中UnityEngine.Keyframe类的典型用法代码示例。如果您正苦于以下问题:C# Keyframe类的具体用法?C# Keyframe怎么用?C# Keyframe使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Keyframe类属于UnityEngine命名空间,在下文中一共展示了Keyframe类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SetObjectData
public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
{
Keyframe[] keyframes;
AnimationCurve curve=new AnimationCurve();
// curve.preWrapMode=(WrapMode)info.GetValue("preWrapMode",typeof(WrapMode));
// curve.postWrapMode=(WrapMode)info.GetValue("postWrapMode",typeof(WrapMode));
int numKeys=info.GetInt32("keysn");
keyframes=new Keyframe[numKeys];
Keyframe keyframeCurrent;
for (int i=0; i<numKeys; i++) {
keyframeCurrent=keyframes[i]=new Keyframe(info.GetSingle("keyt"+i),
info.GetSingle("keyv"+i));
keyframeCurrent.tangentMode=info.GetInt32("keymod"+i);
keyframeCurrent.inTangent=info.GetSingle("keyin"+i);
keyframeCurrent.outTangent=info.GetSingle("keyout"+i);
}
curve.keys = keyframes;
// don't know how to make connection between AnimaitonCurver and Keyframes surrogate
// AnimationCurve surrogate keys are constructed before thoose in Keyframe surrogate resulting in 0,0 Keyframes
//return new AnimationCurve((Keyframe[])info.GetValue ("keys", typeof(Keyframe[])));
return curve;
}
开发者ID:osmanzeki,项目名称:bmachine,代码行数:30,代码来源:AnimationCurveSurrogate.cs
示例2: Interpolate
/// <summary>
/// Creates a new Animationcurve that an interpolation between two other curves. Thanks to Oliver for creating this
/// </summary>
/// <param name="CurveA"></param>
/// <param name="CurveB"></param>
/// <param name="step"></param>
/// <returns>The new interpolated animation curve</returns>
public static AnimationCurve Interpolate(AnimationCurve CurveA, AnimationCurve CurveB, float step)
{
int I = CurveA.length < CurveB.length ? CurveB.length : CurveA.length;
var keys = new Keyframe[I];
for (int i = 0; i < I; ++i)
{
var a = GetKey(CurveA, i, I);
var b = GetKey(CurveB, i, I);
var time = Mathf.SmoothStep(a.time, b.time, step);
var value = Mathf.SmoothStep(a.value, b.value, step);
var inTangent = Mathf.SmoothStep(a.inTangent, b.inTangent, step);
var outTangent = Mathf.SmoothStep(a.outTangent, b.outTangent, step);
var c = new Keyframe(time, value, inTangent, outTangent);
keys[i] = c;
}
return new AnimationCurve(keys);
}
开发者ID:BLueders,项目名称:UnityUtilities,代码行数:32,代码来源:CurveUtilities.cs
示例3: AddKeyframe
public void AddKeyframe(float t, float val)
{
// Simplify keys
if (ReduceKeyframes && keyframes.Count >= 2) {
var keyStart = keyframes[keyframes.Count-2];
var keyEnd = keyframes[keyframes.Count-1];
// UseReductionThreshold: be wary, traveler. works "ok" but is not a sophisticated keyframe reduction technique
if (UseReductionThreshold) {
float deltaStart = Mathf.Abs (keyStart.value - val);
float deltaEnd = Mathf.Abs (keyEnd.value - val);
if ( deltaStart < ReductionThreshold
&& deltaEnd < ReductionThreshold) {
keyEnd.time = t;
keyEnd.value = val;
return;
}
} else {
if ( Mathf.Approximately (keyStart.value, val)
&& Mathf.Approximately (keyEnd.value, val)) {
keyEnd.time = t;
return;
}
}
}
var k = new Keyframe(t, val);
keyframes.Add (k);
}
开发者ID:speregil,项目名称:VRClassroom,代码行数:29,代码来源:Recording.cs
示例4: TreeGroup
public TreeGroup()
{
Keyframe[] keys = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) };
this.distributionCurve = new AnimationCurve(keys);
this.distributionNodes = 5;
this.distributionTwirl = 0f;
this.distributionPitch = 0f;
Keyframe[] keyframeArray2 = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) };
this.distributionPitchCurve = new AnimationCurve(keyframeArray2);
this.distributionScale = 1f;
Keyframe[] keyframeArray3 = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 0.3f) };
this.distributionScaleCurve = new AnimationCurve(keyframeArray3);
this.showAnimationProps = true;
this.animationPrimary = 0.5f;
this.animationSecondary = 0.5f;
this.animationEdge = 1f;
this.visible = true;
this.lockFlags = 0;
this.nodeIDs = new int[0];
this.parentGroupID = -1;
this.childGroupIDs = new int[0];
this.nodes = new List<TreeNode>();
this.parentGroup = null;
this.childGroups = new List<TreeGroup>();
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:25,代码来源:TreeGroup.cs
示例5: TreeGroupBranch
public TreeGroupBranch()
{
Keyframe[] keys = new Keyframe[] { new Keyframe(0f, 1f, -1f, -1f), new Keyframe(1f, 0f, -1f, -1f) };
this.radiusCurve = new AnimationCurve(keys);
this.radiusMode = true;
this.capSmoothing = 0f;
this.crinklyness = 0.1f;
Keyframe[] keyframeArray2 = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) };
this.crinkCurve = new AnimationCurve(keyframeArray2);
this.seekBlend = 0f;
Keyframe[] keyframeArray3 = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) };
this.seekCurve = new AnimationCurve(keyframeArray3);
this.noise = 0.1f;
Keyframe[] keyframeArray4 = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) };
this.noiseCurve = new AnimationCurve(keyframeArray4);
this.noiseScaleU = 0.2f;
this.noiseScaleV = 0.1f;
this.flareSize = 0f;
this.flareHeight = 0.1f;
this.flareNoise = 0.3f;
this.weldHeight = 0.1f;
this.weldSpreadTop = 0f;
this.weldSpreadBottom = 0f;
this.breakingChance = 0f;
this.breakingSpot = new Vector2(0.4f, 0.6f);
this.frondCount = 1;
this.frondWidth = 1f;
Keyframe[] keyframeArray5 = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) };
this.frondCurve = new AnimationCurve(keyframeArray5);
this.frondRange = new Vector2(0.1f, 1f);
this.frondRotation = 0f;
this.frondCrease = 0f;
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:33,代码来源:TreeGroupBranch.cs
示例6: Write
public void Write(SceneWriter writer, object component)
{
AnimationCurve curve = component as AnimationCurve;
if (curve == null)
{
throw new Exception(GetType() + " cannot export components of type " + component.GetType());
}
writer.WriteElement("PreLoop", ConvertLoopType(curve.preWrapMode));
writer.WriteElement("PostLoop", ConvertLoopType(curve.postWrapMode));
StringBuilder sb = new StringBuilder();
// NOTE: Keyframe.tangentMode might say something about if the tangetn is smooth or broken?
Keyframe[] normalizedKeys = new Keyframe[curve.keys.Length];
for (int i = 0; i < curve.keys.Length; i++)
{
Keyframe k = curve.keys[i];
normalizedKeys[i] = new Keyframe(k.time, k.value, k.inTangent, k.outTangent);
if (i > 0)
{
Keyframe j = curve.keys[i - 1];
normalizedKeys[i - 1].outTangent = DenormalizeTangent(j.time, k.time, j.outTangent);
normalizedKeys[i].inTangent = DenormalizeTangent(j.time, k.time, k.inTangent);
}
}
foreach (Keyframe item in normalizedKeys)
{
sb.AppendFormat("{0} {1} {2} {3} {4} ", item.time, item.value, item.inTangent, item.outTangent, "Smooth");
}
writer.WriteElement("Keys", sb.ToString().TrimEnd());
}
开发者ID:Joelone,项目名称:FFWD,代码行数:32,代码来源:AnimationCurveWriter.cs
示例7: FromKeyframe
public void FromKeyframe(Keyframe k)
{
this.inTangent = k.inTangent;
this.outTangent = k.outTangent;
this.time = k.time;
this.value = k.value;
}
开发者ID:kurtdog,项目名称:DoubleTapp,代码行数:7,代码来源:SerializableKeyframe.cs
示例8: AddKeyIfChanged
public static void AddKeyIfChanged(this AnimationCurve curve, Keyframe keyframe)
{
var keys = curve.keys;
//If this is the first key on this curve, always add
//NOTE: Add TWO copies of the first frame, then we adjust the last frame as we move along
//This guarantees a minimum of two keys in each curve
if (keys.Length == 0)
{
curve.AddKey(keyframe);
keyframe.time += float.Epsilon;
curve.AddKey(keyframe);
}
else
{
//TODO: This method of keyframe reduction causes artifacts in animations that are supposed to deliberately pause
//Find the last keyframe
Keyframe lastKey = keys[keys.Length - 1];
if (lastKey.time >= keyframe.time)
Debug.LogError("Keyframes not supplied in consecutive order!!!");
//Grab 2 frames ago
var last2Key = keys[keys.Length - 2];
//If the previous 2 frames were different, add a new frame
if (lastKey.value != last2Key.value)
{
curve.AddKey(keyframe);
}
//The previous frame is redundant - just move it
else
{
curve.MoveKey(keys.Length - 1, keyframe);
}
}
}
开发者ID:pjwaixingren,项目名称:Spriter2Unity,代码行数:35,代码来源:Utils.cs
示例9: ToKeyframeArray
public static Keyframe[] ToKeyframeArray(SerializableKeyframe[] sks)
{
Keyframe[] keys = new Keyframe[sks.Length];
for(int i = 0; i < keys.Length; i++)
keys[i] = sks[i].ToKeyframe();
return keys;
}
开发者ID:kurtdog,项目名称:DoubleTapp,代码行数:7,代码来源:SerializableKeyframe.cs
示例10: FromKeyframeArray
public static SerializableKeyframe[] FromKeyframeArray(Keyframe[] ks)
{
SerializableKeyframe[] keys = new SerializableKeyframe[ks.Length];
for(int i = 0; i < keys.Length; i++)
keys[i] = new SerializableKeyframe(ks[i]);
return keys;
}
开发者ID:kurtdog,项目名称:DoubleTapp,代码行数:7,代码来源:SerializableKeyframe.cs
示例11: constructor
public static int constructor(IntPtr l)
{
try {
int argc = LuaDLL.lua_gettop(l);
UnityEngine.Keyframe o;
if(argc==3){
System.Single a1;
checkType(l,2,out a1);
System.Single a2;
checkType(l,3,out a2);
o=new UnityEngine.Keyframe(a1,a2);
pushValue(l,o);
return 1;
}
else if(argc==5){
System.Single a1;
checkType(l,2,out a1);
System.Single a2;
checkType(l,3,out a2);
System.Single a3;
checkType(l,4,out a3);
System.Single a4;
checkType(l,5,out a4);
o=new UnityEngine.Keyframe(a1,a2,a3,a4);
pushValue(l,o);
return 1;
}
LuaDLL.luaL_error(l,"New object failed.");
return 0;
}
catch(Exception e) {
LuaDLL.luaL_error(l, e.ToString());
return 0;
}
}
开发者ID:terwxqian,项目名称:2DPlatformer-SLua,代码行数:35,代码来源:Lua_UnityEngine_Keyframe.cs
示例12: KFProxy
public KFProxy(Keyframe _val)
{
inTangent = _val.inTangent;
outTangent = _val.outTangent;
tangentMode = _val.tangentMode;
time = _val.time;
value = _val.value;
}
开发者ID:ming4883,项目名称:mud,代码行数:8,代码来源:LookUpTableUtil.cs
示例13: GetAverageKeyValue
private float GetAverageKeyValue(Keyframe[] keyFrames)
{
float num = 0f;
foreach (Keyframe keyframe in keyFrames)
{
num += keyframe.value;
}
return (num / ((float) keyFrames.Length));
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:9,代码来源:SerializedMinMaxCurve.cs
示例14: AnimationWindowKeyframe
public AnimationWindowKeyframe(AnimationWindowCurve curve, Keyframe key)
{
this.time = key.time;
this.value = key.value;
this.curve = curve;
this.m_InTangent = key.inTangent;
this.m_OutTangent = key.outTangent;
this.m_TangentMode = key.tangentMode;
}
开发者ID:demelev,项目名称:projectHL,代码行数:9,代码来源:AnimationWindowKeyframe.cs
示例15: KeyFrameCopy
public KeyFrameCopy(int idx, int selectionIdx, Keyframe source)
{
this.idx = idx;
this.selectionIdx = selectionIdx;
this.time = source.time;
this.value = source.value;
this.inTangent = source.inTangent;
this.outTangent = source.outTangent;
}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:9,代码来源:CurveEditor.cs
示例16: GetKeyTangentMode
// UnityEditor.CurveUtility.cs (c) Unity Technologies
public static TangentMode GetKeyTangentMode(Keyframe keyframe, int leftRight)
{
Type t = typeof( UnityEngine.Keyframe );
FieldInfo field = t.GetField( "m_TangentMode", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance );
int tangentMode = (int)field.GetValue(keyframe);
if (leftRight == 0)
return (TangentMode) ((tangentMode & 6) >> 1);
else
return (TangentMode) ((tangentMode & 24) >> 3);
}
开发者ID:jmurillo7,项目名称:Inteligencia_Artificial2,代码行数:11,代码来源:KeyframeUtil.cs
示例17: SetObjectData
public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
{
float single = info.GetSingle("time");
float single2 = info.GetSingle("value");
int @int = info.GetInt32("tangentMode");
float single3 = info.GetSingle("inTangent");
float single4 = info.GetSingle("outTangent");
Keyframe keyframe = new Keyframe(single, single2, single3, single4);
keyframe.tangentMode = @int;
return keyframe;
}
开发者ID:fuboss,项目名称:aiProject,代码行数:11,代码来源:KeyframeSurrogate.cs
示例18: AddCurve
public void AddCurve()
{
SerializedProperty property = this.Get("curves");
if ((property != null) && property.isArray)
{
property.InsertArrayElementAtIndex(property.arraySize);
property.GetArrayElementAtIndex(property.arraySize - 1).FindPropertyRelative("name").stringValue = "Curve";
Keyframe[] keys = new Keyframe[] { new Keyframe(0f, 0f), new Keyframe(1f, 0f) };
property.GetArrayElementAtIndex(property.arraySize - 1).FindPropertyRelative("curve").animationCurveValue = new AnimationCurve(keys);
}
}
开发者ID:randomize,项目名称:VimConfig,代码行数:11,代码来源:AnimationClipInfoProperties.cs
示例19: Clamp
public static AnimationCurve Clamp(this AnimationCurve curve, float minTime, float maxTime, float minValue, float maxValue) {
for (int i = 0; i < curve.keys.Length; i++) {
Keyframe key = curve.keys[i];
if (key.time < minTime || key.time > maxTime || key.value < minValue || key.value > maxValue) {
var newKey = new Keyframe(Mathf.Clamp(key.time, minTime, maxTime), Mathf.Clamp(key.value, minValue, maxValue));
newKey.inTangent = key.inTangent;
newKey.outTangent = key.outTangent;
curve.MoveKey(i, newKey);
}
}
return curve;
}
开发者ID:Kartoshka,项目名称:Crabby-Pulse-2,代码行数:12,代码来源:AnimationCurveExtensions.cs
示例20: CalculateSmoothTangent
public static float CalculateSmoothTangent(Keyframe key)
{
if (key.inTangent == float.PositiveInfinity)
{
key.inTangent = 0f;
}
if (key.outTangent == float.PositiveInfinity)
{
key.outTangent = 0f;
}
return ((key.outTangent + key.inTangent) * 0.5f);
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:12,代码来源:CurveUtility.cs
注:本文中的UnityEngine.Keyframe类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论