其实概念我都懂但是就是不知道咋用
枚举我懂得用过一次
就是在我想在inspector面板上的时候我如果想有下拉框,就需要
[SerializeField]
private DotweenType _dotweenType = DotweenType.MovementOneWay;
private enum DotweenType
{
MovementOneWay,
MovementTwoWay,
MovementOneWayColorChange,
MovementTwoWayWithSequence,
MovementOneWayColorChangeWithScale
}
这是一次使用
还有一次使用是在kinect中获得相应关节的位置的时候
leftHandPos = kinectManager.GetJointPosition(primaryUserID, (int)KinectInterop.JointType.HandLeft);
public enum JointType : int
{
SpineBase = 0,
SpineMid = 1,
Neck = 2,
Head = 3,
ShoulderLeft = 4,
}
刚刚看到的一个是使用枚举来简化游戏开发
要求是:如果用户按下向上的箭头,剑图标就会淡入淡出,显示它被选中。此时,如果用户再次按下按钮,将执行与up按钮相关的命令。
void Update()
{
//Standard input calls.
if (Input.GetButtonDown("Up"))
{
if (currentSel == Selection.Up)
{
//Executes if we already have up selected and user presses up again
buttonUp.onClick.Invoke(); //Call up button's OnClick() function
currentSel = Selection.None; //set currentSel back to None
}
else
{
currentSel = Selection.Up; // changes currentSel to Up.
StartCoroutine(FadeIcon(imgUp, currentSel)); //Begins fading the icon
}
}
//The same code pattern from above is repeated for the rest of the inputs
else if (Input.GetButtonDown("Down"))
{
if (currentSel == Selection.Down)
{
buttonDown.onClick.Invoke();
currentSel = Selection.None;
}
else
{
currentSel = Selection.Down;
StartCoroutine(FadeIcon(imgDown, currentSel));
}
}
}