Data-OrientedTechnologyStack(DOTS) 記錄及遇到的問題

////////////////////////////////////////////////

Use ECS and data-oriented design!

Difficulty Rating Outline: * 1: Easier, no concurrent data dependencies * 2: Moderate, concurrent reads and writes * 3: Difficult, lots of concurrency, data design problems to solve

//////////////////////////////////////////////////////

Installing the Unity Editor

To install the Editor:

Click the Installs tab. The default install locations are:

Windows:

C:\Program Files\Unity\Hub\Editor

Mac:

/Applications/Unity/Hub/Editor

Note: If you want to change the default installation location, follow these steps:

From the top right corner of the Hub window, click the Gear icon.

In the Editor Folder Location dialog box, enter the new installation location and click Done.

//////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////

AssetStore下載的文件夾

C:\Users\自己電腦名字\AppData\Roaming\Unity\Asset Store-5.x

///////////////////////////////////////////////////////////////

 

 

 

////////////////////////////////////////////

ConvertAndDestroy 會讓轉化後消失

///////////////////////////////////////

[GenerateAuthoringComponent]

public struct RotationSpeed_ForEach : IComponentData

{

    public float RadiansPerSecond;

}

 

[RequiresEntityConversion]

[AddComponentMenu("DOTS Samples/IJobChunk/Rotation Speed")]

[ConverterVersion("joe", 1)]

public class RotationSpeedAuthoring_IJobChunk : MonoBehaviour, IConvertGameObjectToEntity

{

    public float DegreesPerSecond = 360.0F;

 

    // The MonoBehaviour data is converted to ComponentData on the entity.

    // We are specifically transforming from a good editor representation of the data (Represented in degrees)

    // To a good runtime representation (Represented in radians)

    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)

    {

        var data = new RotationSpeed_IJobChunk { RadiansPerSecond = math.radians(DegreesPerSecond) };

        dstManager.AddComponentData(entity, data);

    }

}

//////////////////////////////////////////////////////////////////////

 

DebugStream.DrawComponent

 

/////////////////////

運行EntityComponentSystemSamples\UnityPhysicsSamples 把[email protected]下邊報錯的Test文件夾刪除

/////////////////////////////////////////

 

 

 

///////////////////////////////////////////////////////

using System;

using Unity.Entities;

using Unity.Mathematics;

using UnityEngine;

 

[Serializable]

public struct ActorComponent : IComponentData

{

    public float3 position;

    public float3 target_positon;

}

 

[DisallowMultipleComponent]

[RequiresEntityConversion]

public class Actor : MonoBehaviour, IConvertGameObjectToEntity

{

    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)

    {

        float3 grid_pos = new float3(

            math.floor(transform.position.x),

            0,

            math.floor(transform.position.z)

            );

 

        dstManager.AddComponentData(entity, new ActorComponent()

        {

            position = grid_pos,

            target_positon = grid_pos,

        });

    }

}

在這個Cube (2)上加上Actor腳本,需要加上ConvertToEntity腳本

/////////////////////////////////////////////////////////////////

 

 

 

 

EntityQuery _query

[ReadOnly] public CollisionWorld MCollisionWorld;

var chunkTranslations = chunk.GetNativeArray(TranslationType);

Random random_

public float3 Direction;

CustomCopyTransformToGameObjectSystem m_CustomCopyTransformToGameObjectSystem

 

/////////////////////////////////運行官網最新2019的一些例子時////////////////////////////////////////

運行效果和官網描述差別很大:
運行DxDiag.exe
檢測顯卡支持不支持DX12

 

 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章