unity 里面的animator.unity setfloatt方法有什么用

推荐这篇日记的豆列
······.SetFloat 设置浮点键值
static function SetFloat (key : string, value : float) : void
Description描述
Sets the value of the preference identified by key.
设置由key确定的参数值。
using UnityE
using System.C
public class example :
public void Awake() {
PlayerPrefs.SetFloat(&Player Score&, 10.0F);
PlayerPrefs.SetFloat(&Player Score&, 10.0);
本脚本参考基于Unity 3.4.1f5英文部分版权属&公司所有,中文部分&
版权所有,未经许可,严禁转载 。Navigation
Unity Account
You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio.
Animator Scripting
Animator Scripting
Checked with version: 4.3
Difficulty: Beginner
Scripting is what allows us to really bring a model's animations to life. In this video you will learn how to utilize the animator class in code to control awesome animations.
EthanScript
Code snippetusing UnityE
using System.C
public class EthanScript : MonoBehaviour
int jumpHash = Animator.StringToHash(&Jump&);
int runStateHash = Animator.StringToHash(&Base Layer.Run&);
void Start ()
anim = GetComponent&Animator&();
void Update ()
float move = Input.GetAxis (&Vertical&);
anim.SetFloat(&Speed&, move);
AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0);
if(Input.GetKeyDown(KeyCode.Space) && stateInfo.nameHash == runStateHash)
anim.SetTrigger (jumpHash);
}#pragma strict
var anim : A
var jumpHash : int = Animator.StringToHash(&Jump&);
var runStateHash : int = Animator.StringToHash(&Base Layer.Run&);
function Start ()
anim = GetComponent(&Animator&);
function Update ()
var move : float = Input.GetAxis (&Vertical&);
anim.SetFloat(&Speed&, move);
var stateInfo : AnimatorStateInfo = anim.GetCurrentAnimatorStateInfo(0);
if(Input.GetKeyDown(KeyCode.Space) && stateInfo.nameHash == runStateHash)
anim.SetTrigger (jumpHash);
}import UnityEngine
import System.Collections
public class EthanScript(MonoBehaviour):
private anim as Animator
private jumpHash as int = Animator.StringToHash('Jump')
private runStateHash as int = Animator.StringToHash('Base Layer.Run')
private def Start():
anim = GetComponent()
private def Update():
move as single = Input.GetAxis('Vertical')
anim.SetFloat('Speed', move)
stateInfo as AnimatorStateInfo = anim.GetCurrentAnimatorStateInfo(0)
if Input.GetKeyDown(KeyCode.Space) and (stateInfo.nameHash == runStateHash):
anim.SetTrigger(jumpHash)
Animator Controller Layers
Blend Trees
Related tutorials
Related documentation
(Script Reference)
Controlling Animation
Animator Scripting
Character Animation
Live Sessions on Animation
Community Posts on Animation
Quick links
About Unity
Get Unity news
I agree to the
and the processing and use of my information
Nearly there...
To start receiving news from Unity Technologies, click on the link we've sent to your e-mail account.
Something went wrong, please try again.
Copyright & 2016 Unity Technologies
We use cookies to ensure that we give you the best experience on our website. Click
for more information.

我要回帖

更多关于 unity animator 播放 的文章

 

随机推荐