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

49 行
1.3 KiB

using System.Collections.Generic;
using Unity.Entities;
using UnityEditor;
using UnityEngine;
#if UNITY_EDITOR
public interface IPrefabAsset
{
}
public class PrefabAssetRegistryAuthoring : MonoBehaviour, IConvertGameObjectToEntity , IDeclareReferencedPrefabs
{
public List<GameObject> Assets = new List<GameObject>();
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
var buffer = dstManager.AddBuffer<PrefabAssetRegistry.Entry>(entity);
for (int i = 0; i < Assets.Count; i++)
{
var assetPath = AssetDatabase.GetAssetPath(Assets[i]);
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath);
var reference = new WeakAssetReference(assetGUID);
var prefabEntity = conversionSystem.GetPrimaryEntity(Assets[i]);
buffer.Add(new PrefabAssetRegistry.Entry
{
Reference = reference,
EntityPrefab = prefabEntity,
});
}
dstManager.AddComponentData(entity, new PrefabAssetRegistry.State());
}
public void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
{
for (int i = 0; i < Assets.Count; i++)
{
referencedPrefabs.Add(Assets[i]);
}
}
}
#endif