该项目的目的是同时测试和演示来自 Unity DOTS 技术堆栈的多个新包。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

41 行
1.4 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
public class DamageAreaAuthoring : MonoBehaviour, IConvertGameObjectToEntity
{
public bool instantKill = false;
public float hitsPerSecond = 3;
public float damagePerHit = 25;
public float3 size = new float3(5, 5, 5);
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
var da = new DamageArea();
da.instantKill = instantKill;
da.hitsPerSecond = hitsPerSecond;
da.damagePerHit = damagePerHit;
da.size = size*0.5f; // we prefer the runtime to be the extend along each axis, not total size
dstManager.AddComponentData(entity, da);
}
#if UNITY_EDITOR
void OnDrawGizmosSelected()
{
Gizmos.matrix = transform.localToWorldMatrix;
if (gameObject == UnityEditor.Selection.activeGameObject)
{
// If we are directly selected (and not just our parent is selected)
// draw with negative size to get an 'inside out' cube we can see from the inside
Gizmos.color = new Color(1.0f, 1.0f, 0.5f, 0.8f);
Gizmos.DrawCube(Vector3.zero, -size);
}
Gizmos.color = new Color(1.0f, 0.5f, 0.5f, 0.3f);
Gizmos.DrawCube(Vector3.zero, size);
}
#endif
}