您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
26 行
708 B
26 行
708 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Unity.Entities;
|
|
|
|
public class PaddleConversion : MonoBehaviour, IConvertGameObjectToEntity
|
|
{
|
|
public int playerID;
|
|
public float speed = 3f;
|
|
public KeyCode upKey;
|
|
public KeyCode downKey;
|
|
|
|
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
|
|
{
|
|
dstManager.AddComponentData(entity, new PlayerData { playerID = playerID });
|
|
|
|
dstManager.AddComponentData(entity, new PaddleMovementData { direction = 0, speed = speed });
|
|
|
|
PlayerInputData data = new PlayerInputData
|
|
{
|
|
upKey = upKey,
|
|
downKey = downKey
|
|
};
|
|
dstManager.AddComponentData(entity, data);
|
|
}
|
|
}
|