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

50 行
1.4 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.VFX;
[Serializable]
public class TeleporterClientDataClass : IComponentData, IEquatable<TeleporterClientDataClass>
{
public VisualEffectAsset effect;
public bool Equals(TeleporterClientDataClass other)
{
return effect != null && other.effect != null && other.effect.Equals(effect);
}
public override int GetHashCode()
{
return effect != null ? effect.GetHashCode() : 0;
}
}
public struct TeleporterClientData : IComponentData
{
public TickEventHandler effectEvent;
public float3 effectPos;
}
[DisallowMultipleComponent]
[ClientOnlyComponent]
public class TeleporterClient : MonoBehaviour, IConvertGameObjectToEntity
{
public VisualEffectAsset effect;
public Transform effectTransform;
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
var shared = new TeleporterClientDataClass();
shared.effect = effect;
dstManager.AddComponentData(entity, shared);
var data = new TeleporterClientData();
data.effectEvent = new TickEventHandler(0.5f);
data.effectPos = effectTransform.localPosition;
dstManager.AddComponentData(entity, data);
}
}