当前位置: 首页>>代码示例>>C#>>正文


C# AnimationCurve.AddKey方法代码示例

本文整理汇总了C#中UnityEngine.AnimationCurve.AddKey方法的典型用法代码示例。如果您正苦于以下问题:C# AnimationCurve.AddKey方法的具体用法?C# AnimationCurve.AddKey怎么用?C# AnimationCurve.AddKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.AnimationCurve的用法示例。


在下文中一共展示了AnimationCurve.AddKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: defineCurve

    //Create default curve for the dynamic bias
    private AnimationCurve defineCurve()
    {
        AnimationCurve temp = new AnimationCurve();
        temp.AddKey(-1, -1);
        temp.AddKey(-0.55f, -0.95f);
        temp.AddKey(-0.001f, -0.5f);
        temp.AddKey(0.001f, 0.5f);
        temp.AddKey(0.55f, 0.95f);
        temp.AddKey(1, 1);
        temp.SmoothTangents(2, 1);
        temp.SmoothTangents(3, -1);

        return temp;
    }
开发者ID:Ed-McD,项目名称:Unity-Editor-Maze-Generator,代码行数:15,代码来源:MazeMenu.cs

示例2: AbstractForceController

        /// <summary>
        /// Constructor
        /// </summary>
        public AbstractForceController()
            : base(ControllerType.AbstractForceController)
        {
            Enabled = true;

            Strength = 1.0f;
            Position = new Vector2(0, 0);
            MaximumSpeed = 100.0f;
            TimingMode = TimingModes.Switched;
            ImpulseTime = 0.0f;
            ImpulseLength = 1.0f;
            Triggered = false;
            StrengthCurve = new AnimationCurve();
            Variation = 0.0f;
            Randomize = new System.Random(1234);
            DecayMode = DecayModes.None;
            DecayCurve = new AnimationCurve();
            DecayStart = 0.0f;
            DecayEnd = 0.0f;

            StrengthCurve.AddKey(0, 5);
            StrengthCurve.AddKey(0.1f, 5);
            StrengthCurve.AddKey(0.2f, -4);
            StrengthCurve.AddKey(1f, 0);
        }
开发者ID:kyallbarrows,项目名称:Cinch_4-3,代码行数:28,代码来源:AbstractForceController.cs

示例3: Interpolators

    static Interpolators()
    {
        // See: http://www.alsacreations.com/tuto/lire/876-transitions-css3-transition-timing-function.html
        LinearCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f);

        EaseOutCurve = new AnimationCurve();
        EaseOutCurve.AddKey(new Keyframe(0f, 0f)
        {
          inTangent = 2,
          outTangent = 2,
          tangentMode = 0
        });
        EaseOutCurve.AddKey(new Keyframe(1f, 1f)
        {
          inTangent = 0,
          outTangent = 0,
          tangentMode = 0
        });

        EaseInCurve = new AnimationCurve();
        EaseInCurve.AddKey(new Keyframe(0f, 0f)
        {
          inTangent = 0,
          outTangent = 0,
          tangentMode = 0
        });
        EaseInCurve.AddKey(new Keyframe(1f, 1f)
        {
          inTangent = 2,
          outTangent = 2,
          tangentMode = 0
        });

        EaseInOutCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
    }
开发者ID:valryon,项目名称:hitsplayjam-2015,代码行数:35,代码来源:Interpolators.cs

示例4: Start

    // Use this for initialization
    void Start()
    {
        m_InitialPosition = gameObject.transform.localPosition;
        m_RelPosition.Set(0, 0, 0);
        m_Translations = new Vector3[3];
        m_Translations[0].Set(m_Speed, 0, 0);
        m_Translations[1].Set(0, m_Speed, 0);
        m_Translations[2].Set(0, 0, m_Speed);

        gameObject.AddComponent<Animation>();
        gameObject.animation.animatePhysics = true;
        m_Forward = new AnimationClip();

        var curvex = new AnimationCurve();
        var curvey = new AnimationCurve();
        var curvez = new AnimationCurve();
        var minpos = m_InitialPosition+m_MinIncrement;
        var maxpos = m_InitialPosition-m_MaxIncrement;
        float dist = (minpos-maxpos).magnitude;
        m_MaxTime = dist/m_Speed;
        curvex.AddKey(0f, minpos.x);
        curvex.AddKey(dist/m_Speed, maxpos.x);
        curvey.AddKey(0f, minpos.y);
        curvey.AddKey(dist/m_Speed, maxpos.y);
        curvez.AddKey(0f, minpos.z);
        curvez.AddKey(dist/m_Speed, maxpos.z);
        m_Forward.wrapMode = WrapMode.ClampForever;

        m_Forward.SetCurve("", typeof(Transform), "localPosition.x", curvex);
        m_Forward.SetCurve("", typeof(Transform), "localPosition.y", curvey);
        m_Forward.SetCurve("", typeof(Transform), "localPosition.z", curvez);
        this.animation.AddClip(m_Forward, "Forward");
        this.animation.Play("Forward");
        m_ForwardState = this.animation["Forward"];
    }
开发者ID:Agamand,项目名称:DualityScript,代码行数:36,代码来源:AutomatedMovingPlatformScript.cs

示例5: GetNewCurve

 AnimationCurve GetNewCurve()
 {
     AnimationCurve newCurve = new AnimationCurve();
     newCurve.AddKey(0f, 0f);
     newCurve.AddKey(1f, 1f);
     return newCurve;
 }
开发者ID:mmandel,项目名称:8Nights2,代码行数:7,代码来源:CurvePayload.cs

示例6: Init

    public override void Init()
    {
        base.Init();

        m_FlyCurve = new AnimationCurve();
        m_FlyCurve.AddKey(new Keyframe() { time = 0f, value = 0f });
        m_FlyCurve.AddKey(new Keyframe() { time = 1f, value = 1f });
    }
开发者ID:co-chi-tam,项目名称:The-Dark-Creature,代码行数:8,代码来源:TDCFlyAIController.cs

示例7: Rebuild

	/// <summary>
	/// Rebuild all Lookup tables for the path... This should be called when ever the samples number changes or any points are moved
	/// </summary>
	public void Rebuild()
	{
		// Scrap old curves
		uvLUT = new AnimationCurve();
		xLUT = new AnimationCurve();
		yLUT = new AnimationCurve();
		zLUT = new AnimationCurve();
		
		// Add known start and end points to uvLUT
		uvLUT.AddKey(0,0);
		uvLUT.AddKey(1,1);
		
		
		samples = Mathf.Max(samples, 2);												// Force samples to always be greater than 1
		float uvStepSize = (1.0f / (controlPoints.Length - 1)) / samples;		// This is how much we increase our iTween.PointOnPath amount by each evaluation
		
		float pathLength = length;															// Get length of path from iTween
		float distanceTraveled = 0;															// Keep track of actual distance traveled along the path
		float sampleUV = uvStepSize;														// Set initial sample point to uvStepSize, there is no need to sample position 0
		Vector3 sampleCurrent = controlPoints[0];									// Current point sampled
		Vector3 sampleLast = controlPoints[0];										// Previous point sampled - used to get distance and normal
		Vector3 normal = Vector3.forward;											// Normal from last point to current point
		
		while(sampleUV < 1)
		{
			sampleCurrent = iTween.PointOnPath(controlPoints, sampleUV); 			// Sample point from iTween
			distanceTraveled += Vector3.Distance(sampleLast, sampleCurrent);		// Increment distance traveled
			float factor = distanceTraveled / pathLength;										// Get percentage in actual distance that distanceTraveled = of pathLength
			uvLUT.AddKey(factor, sampleUV);														// Add key on Lookup table
			
			normal = (sampleCurrent - sampleLast).normalized;								// Normal from last sample point to current
			xLUT.AddKey(sampleUV, normal.x);														// Save each component of the normal to their own curves
			yLUT.AddKey(sampleUV, normal.y);
			zLUT.AddKey(sampleUV, normal.z);
			
			sampleUV += uvStepSize;																	// Increament sampleUV by uvStepSize
			sampleLast = sampleCurrent;																// Save current point as last
			
		}
		
		if (controlPoints[0] == controlPoints[controlPoints.Length-1])						// Check if first and last points are equal... if so make sure the normal LUTs loop as well
		{
			looping = true;
			sampleCurrent = iTween.PointOnPath(controlPoints, 1);
			normal = (sampleCurrent - sampleLast).normalized;
			xLUT.AddKey(0, normal.x);
			yLUT.AddKey(0, normal.y);
			zLUT.AddKey(0, normal.z);
			
			xLUT.AddKey(1, normal.x);
			yLUT.AddKey(1, normal.y);
			zLUT.AddKey(1, normal.z);
		}
		else
			looping = false;
		
	}
开发者ID:GDxU,项目名称:incomplete-richman,代码行数:60,代码来源:MotionPath.cs

示例8: DefaultCurve

 private static AnimationCurve DefaultCurve()
 {
     AnimationCurve curve = new AnimationCurve();
     curve.AddKey(0, 0);
     curve.AddKey(0.5f, 1);
     curve.AddKey(1, 0);
     curve.preWrapMode = WrapMode.Loop;
     curve.postWrapMode = WrapMode.Loop;
     return curve;
 }
开发者ID:Clavus,项目名称:Tank,代码行数:10,代码来源:GlowPulseScript.cs

示例9: SineCurve

	public static AnimationCurve SineCurve(float length, float magnitude) {
		AnimationCurve a = new AnimationCurve();
			a.preWrapMode = WrapMode.Loop;
			a.postWrapMode = WrapMode.Loop;
			a.AddKey(0				,	0);
			a.AddKey(.25f * length	,	-magnitude);
			a.AddKey(.5f * length	,	0);
			a.AddKey(.75f * length	,	magnitude);
			a.AddKey(length			,	0);
			return a;
	}
开发者ID:wfowler1,项目名称:Miscellaneous-Soundboards,代码行数:11,代码来源:Curves.cs

示例10: Init

    public override void Init()
    {
        base.Init();

        m_FlyCurve = new AnimationCurve();
        m_FlyCurve.AddKey(new Keyframe() { time = 0f, value = 0f });
        m_FlyCurve.AddKey(new Keyframe() { time = 1f, value = 1f });

        m_FSMManager.RegisterCondition("IsFarEnoughFly", IsFarEnoughFly);

        m_FSMManager.LoadFSM(m_Entity.GetFSMPath());
    }
开发者ID:co-chi-tam,项目名称:The-Dark-Creature,代码行数:12,代码来源:TDCFlyPlayerController.cs

示例11: CalculateCurve

    static void CalculateCurve(Vector3 pos1, Vector3 pos2, AnimationCurve curve, out float distance)
    {
        {
            var t1 = pos1;
            t1.y = 0f;
            var t2 = pos2;
            t2.y = 0f;
            distance = Vector3.Distance( t1, t2 );
        }

        curve.Clear();
        curve.AddKey( 0f, pos1.y );
        curve.AddKey( 0.5f, distance * Constants.instance.jumpCurveHeightDifference + Mathf.Max( pos1.y, pos2.y ) );
        curve.AddKey( 1f, pos2.y );
    }
开发者ID:Raze,项目名称:BitWars,代码行数:15,代码来源:JumpNode.cs

示例12: createAnimation

    public static void createAnimation()
    {
        GameObject go = GameObject.Find(GAME_OBJECT_NAME);
        if (go != null)
            removeGameObjectAndComponents(go);

        Animator animator;
        go = createGameObjects(out animator);
        AnimationClip animationClip = new AnimationClip();
        AnimationUtility.SetAnimationType(animationClip, ModelImporterAnimationType.Generic);

        AnimationCurve activeCurve = new AnimationCurve();
        AnimationCurve positionLineCurve = new AnimationCurve();
        AnimationCurve positionSmoothCurve = new AnimationCurve();

        for (int i = 0; i < stepValues.Length; i++) {
            float time = stepTime * i;
            activeCurve        .AddKey(KeyframeUtil.GetNew(time, stepValues[i]    , TangentMode.Stepped));
            positionLineCurve  .AddKey(KeyframeUtil.GetNew(time, stepValues[i] + 2, TangentMode.Linear));
            positionSmoothCurve.AddKey(KeyframeUtil.GetNew(time, stepValues[i] - 2, TangentMode.Smooth));
        }

        //this will be linear curve, so need to update tangents (should be after keyframes assignments)
        positionLineCurve.UpdateAllLinearTangents();

        animationClip.SetCurve(CUBE1_NAME, typeof(GameObject),"m_IsActive", activeCurve);
        animationClip.SetCurve(CUBE2_NAME, typeof(Transform),"localPosition.x", positionLineCurve);
        animationClip.SetCurve(CUBE2_NAME, typeof(Transform),"localPosition.y", positionSmoothCurve);

        AssetDatabase.CreateAsset(animationClip, ANIMATION_CLIP_PATH);
        AssetDatabase.SaveAssets();
        AddClipToAnimatorComponent(go, animator, animationClip);
    }
开发者ID:nicloay,项目名称:unity-work-with-curve,代码行数:33,代码来源:CreateAnimation.cs

示例13: Start

    // Use this for initialization
    void Start()
    {
        Animation anim = GetComponent<Animation> ();
        AnimationCurve curve = new AnimationCurve();
        curve.AddKey (0, 1);
        //curve.AddKey (1, 2);
        //curve.AddKey (2, 3);
        curve.AddKey (3, 4);
        curve.AddKey (6, -4);

        AnimationClip clip = new AnimationClip ();
        clip.legacy = true;
        clip.SetCurve ("", typeof(Transform), "localPosition.x", curve);
        anim.AddClip (clip, "test");
        //anim.PlayQueued ("test2", QueueMode.CompleteOthers);

        //anim ["test"].speed = 3;
        anim.Play ("test");
    }
开发者ID:Hyunsik-Yoo,项目名称:Flood-Simulation,代码行数:20,代码来源:anim_script.cs

示例14: FromXMLtoAnimationCurve

 public static AnimationCurve FromXMLtoAnimationCurve(XmlNode node)
 {
     AnimationCurve output = new AnimationCurve();
     if(node == null || !node.HasChildNodes)
     {
         output.AddKey(0, 1);
         output.AddKey(1, 1);
         return output;
     }
     foreach(XmlNode keyframeNode in node.SelectNodes("keyframe"))
     {
         Keyframe keyFrame = new Keyframe();
         keyFrame.inTangent = float.Parse(keyframeNode["inTangent"].FirstChild.Value);
         keyFrame.outTangent = float.Parse(keyframeNode["outTangent"].FirstChild.Value);
         keyFrame.time = float.Parse(keyframeNode["time"].FirstChild.Value);
         keyFrame.value = float.Parse(keyframeNode["value"].FirstChild.Value);
         output.AddKey(keyFrame);
     }
     return output;
 }
开发者ID:onewheelstudio,项目名称:FTF,代码行数:20,代码来源:XMLVariableConverter.cs

示例15: Start

    void Start()
    {
        m_InitialPosition = gameObject.transform.localPosition;
        m_WorldControler = GameObject.Find("GameWorld").GetComponent<WorldControllerScript>();
        m_CurrentWorldNumber = m_WorldControler.GetCurrentWorldNumber();
        m_RelPosition.Set(0, 0, 0);
        m_Translations = new Vector3[3];
        m_Translations[0].Set(m_Speed, 0, 0);
        m_Translations[1].Set(0, m_Speed, 0);
        m_Translations[2].Set(0, 0, m_Speed);
        m_BumpersRenderer = new Renderer[2];
        m_BumpersRenderer[0] = gameObject.transform.FindChild("bumperLeft").GetComponent<Renderer>();
        m_BumpersRenderer[1] = gameObject.transform.FindChild("bumperRight").GetComponent<Renderer>();
        m_LastUpdateWorldNumber = 0;
        m_IsMoving = true;

        gameObject.AddComponent<Animation>();
        gameObject.animation.animatePhysics = true;
        m_Forward = new AnimationClip();

        var curvex = new AnimationCurve();
        var curvey = new AnimationCurve();
        var curvez = new AnimationCurve();
        var minpos = m_InitialPosition+m_MinIncrement;
        var maxpos = m_InitialPosition-m_MaxIncrement;
        float dist = (minpos-maxpos).magnitude;
        m_MaxTime = dist/m_Speed;
        curvex.AddKey(0f, minpos.x);
        curvex.AddKey(dist/m_Speed, maxpos.x);
        curvey.AddKey(0f, minpos.y);
        curvey.AddKey(dist/m_Speed, maxpos.y);
        curvez.AddKey(0f, minpos.z);
        curvez.AddKey(dist/m_Speed, maxpos.z);
        m_Forward.wrapMode = WrapMode.ClampForever;

        m_Forward.SetCurve("", typeof(Transform), "localPosition.x", curvex);
        m_Forward.SetCurve("", typeof(Transform), "localPosition.y", curvey);
        m_Forward.SetCurve("", typeof(Transform), "localPosition.z", curvez);
        this.animation.AddClip(m_Forward, "Forward");
        this.animation.Play("Forward");
    }
开发者ID:Agamand,项目名称:DualityScript,代码行数:41,代码来源:MovingPlatformScript.cs


注:本文中的UnityEngine.AnimationCurve.AddKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。