Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

36 行
923 B

using System;
using System.Collections.Generic;
using UnityEngine;
using Unity.Mathematics;
using Unity.Entities;
public class BuoyancyVisualizer : MonoBehaviour, IConvertGameObjectToEntity
{
public Entity boat;
private void OnDrawGizmos()
{
if (!Application.isPlaying)
return;
DynamicBuffer<VoxelHeight> heights = World.Active.EntityManager.GetBuffer<VoxelHeight>(boat);
DynamicBuffer<VoxelOffset> offsets = World.Active.EntityManager.GetBuffer<VoxelOffset>(boat);
Gizmos.color = Color.red;
for (int i = 0; i < heights.Length; i++)
Gizmos.DrawSphere(new Vector3(transform.position.x + offsets[i].Value.x, heights[i].Value.y, offsets[i].Value.z + transform.position.z), .1f);
}
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
if (boat == Entity.Null)
{
boat = conversionSystem.GetPrimaryEntity(transform.parent);
}
}
}