问题标签 [unity-ecs]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
1809 浏览

unity3d - 如何使用 DOTS 生成单位?

我正在关注此演讲https://www.youtube.com/watch?v=BNMrevfB6Q0并尝试了解如何在单击鼠标时生成单位(用于测试目的)。

一般来说,我创建了一个 UnitBase 等,它实现了 IConvertGameObjectToEntity::Convert 以确保所有单位都可以转换为实体对象,如下所示:

这些是主要组件:

现在,在我的测试脚本中,我有这个:

其中 unitPrefab 只是一个简单的 GameObject,上面有一个 Capsule 和一个基本上是空的脚本,现在是空的:

问题是,当我单击时,实体被创建但单元没有被渲染。

显然我错过了一些东西,但我不明白它是什么。

任何帮助将非常感激!

0 投票
1 回答
243 浏览

c# - 使用扩展方法和单例类封装Unity ECS,你怎么看?

我一直在考虑使用扩展方法和一次性单例类对 Unity ECS 进行一些封装,以保留对 BlobAssetStore 或 EntityManager 等公共资源的引用,类似于此草案:

您如何看待这种做法?

0 投票
1 回答
642 浏览

unity3d - EntityQueryBuilder.ForEach 没有使用两个 ComponentData 和一个 BufferElementData 进行编译

我正在使用 Unity 实体组件系统。当我尝试编写以下代码时:

我收到以下错误error CS0315: The type 'Unity.Entities.Entity' cannot be used as type parameter 'T0' in the generic type or method 'EntityQueryBuilder.ForEach<T0>(EntityQueryBuilder.F_D<T0>)'. There is no boxing conversion from 'Unity.Entities.Entity' to 'Unity.Entities.IComponentData'.

当我只使用一个 ComponentData 和一个 BufferElementData 时,它编译得很好,即以下工作:

我查看了 ForEach 代码,它是生成的代码,其中包含许多组件和动态缓冲区的排列,但我找不到这个。 (请参阅答案 - 我只是看的不够努力!)在不支持 ComponentData 和 BufferElementData 的排列的情况下会发生什么?

0 投票
1 回答
901 浏览

unity3d - How do you reference an array item within nativeArrray in ECS

I'm trying to do the following:

#xA;

But the line that assigns targetData.targetEntity = playerEntity; throws the error:

Cannot implicitly convert type 'Unity.Collections.NativeArray<Unity.Entities.Entity>' to 'Unity.Entities.Entity'

0 投票
1 回答
1708 浏览

unity3d - Unity 实体不在播放模式下渲染

我尝试使用代码实例化一个实体:

我尝试使用 ConvertToEntity 脚本。我还创建了一个子场景,所有三种方法都没有渲染。我可以在 Entity Debugger 中看到实体,所有实体都有一个 Translation,以及相关的渲染组件,一切看起来都不错。这些是我安装的 ECS 包:

  • 爆发 1.3.3
  • 集合 0.9.0-preview.6
  • 实体 0.11.1-preview.4
  • 混合渲染器 0.5.2-preview.4
  • 乔布斯 0.2.10-preview.12

使用 Unity 2020.1.0b12.3931

欢迎任何建议和想法

0 投票
0 回答
1719 浏览

unity3d - 如何使 Unity DOTS Physics Ray cast 与 ECS 配合使用?

问题:我有 3 个游戏对象,它们具有 PhysicShape 和 PhysicBody(static) 组件。我将其转换为实体并进入场景。我不认为物体会相互碰撞,所以我尝试让 Ray cast 在它们碰撞之前处理另一个物体。但似乎我做错了什么,Ray cast 没有“看到”其他对象(它们都在一层,都是实体)。

我的雷演员代码

0 投票
1 回答
291 浏览

unity3d - Visual Scripting Dots Package Assemble issue

So I just created a new project to mess around with visual scripting, ECS and DOTS but I'm having some issues to get some of the unity physics stuff to work VisualScriptingPhysics.cs it says that it has Assemble reference missing but I have check the docs and it has all the references it would need to work what am I missing

I'm getting 2 errors in the console

Library\PackageCache\com.unity.visualscripting.entities@0.4.0-preview.1\Runtime\VisualScriptingPhysics.cs(94,58): error CS0246: The type or namespace name 'ICollisionEventsJob' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.unity.visualscripting.entities@0.4.0-preview.1\Runtime\VisualScriptingPhysics.cs(94,39): error CS0246: The type or namespace name 'ITriggerEventsJob' could not be found (are you missing a using directive or an assembly reference?)

witch is referencing this struct CollectCollisionsJob : ITriggerEventsJob, ICollisionEventsJob witch is in VisualScriptingPhysics.cs a part of Visual Scripting package for it to be compatible with unity physics and the reference that it says it needs in the doc is Unity.Physics witch is at the top of the code would there be any way to fix this manual please let me know

full code for the file that is throwing error keep in mind that this is part of a package and not my code let me know if its something I can fix or do I have to wait till unity update their package

here is all the packages I have installed with the version and date they were updated i have tried to change the version of a different package but keep getting the same error

Burst Version 1.3.3 - June 26, 2020

Castle Core Version 1.0.1 - June 13, 2019

Collections Version 0.11.0-preview.17 - July 22, 2020

Custom NUnit Version 1.0.0 - April 03, 2019

Entities Version 0.13.0-preview.24 - July 22, 2020

Graph Tools Foundation Version 0.3.0-preview.1 - July 31, 2020

Havok Physics for Unity Version 0.3.1-preview - July 28, 2020

Hybrid Renderer Version 0.7.0-preview.24 - July 22, 2020

Input System Version 1.0.0 - April 29, 2020

Jobs Version 0.4.0-preview.18 - July 22, 2020

Mathematics Version 1.1.0 - July 11, 2019

Mono Cecil Version 0.1.5-preview - April 03, 2019

Moq Version 1.0.0 - June 13, 2019

Newtonsoft Json Version 2.0.0-preview - December 13, 2019

Performance testing API Version 2.2.0-preview - May 27, 2020

Platforms Version 0.6.0-preview.1 - July 07, 2020

Properties Version 1.3.1-preview - June 17, 2020

Properties UI Version 1.3.1-preview - June 18, 2020

Scriptable Build Pipeline Version 1.6.4-preview - February 11, 2020

Searcher Version 4.0.9 - November 11, 2019

Serialization Version 1.3.1-preview - June 18, 2020

Test Framework Version 1.1.16 - July 27, 2020

TextMeshPro Version 3.0.1 - July 27, 2020

Timeline Version 1.3.4 - June 11, 2020

Unity Collaborate Version 1.3.8 - June 12, 2020

Unity Physics Version 0.4.1-preview - July 27, 2020

Unity UI Version 1.0.0 - August 05, 2020

Visual Scripting ECS Version 0.4.0-preview.1 - July 31, 2020

Visual Studio Code Editor Version 1.2.1 - May 20, 2020

Visual Studio Editor Version 2.0.2 - June 02, 2020

0 投票
1 回答
64 浏览

unity3d - Unity ECS 系统在命名空间更改后中断

我刚刚意识到在一些(据称)无害的重构更改之后,我的游戏逻辑崩溃了。

通过我的 VCS 历史记录和一些调试,我发现问题是由导致问题的系统的命名空间更改引起的。

奇怪的是系统似乎仍然可以工作,更新我的实体的平移和旋转的部分仍然被调用(从断点/日志消息中可以看出),但是,没有任何更改反映在渲染或实际组件中.

0 投票
1 回答
181 浏览

unity3d - 当我调整视图时,统一场景和游戏视图中的对象正在消失

所以我正在尝试学习 Unity DOTS,并且我已经构建了一个渲染一堆立方体的程序。但是由于某种原因,在游戏视图和场景视图中,当我移动相机时,屏幕边缘的立方体开始消失。我不知道是否可能有一些设置导致不可见的对象不被渲染或某些东西,或者可能与它们成为实体有关?

这是我用来生成瓷砖的代码:

显示剪辑的屏幕截图

0 投票
0 回答
124 浏览

unity3d - 如何在 Unity DOTS 中冻结/约束 PhysicsBody 的旋转?

我试图从 Unity Engine 移植一个小型测试项目,以了解 Unity New Fishers DOTS && ECS。

这是一个小项目,我有一个带 a 的胶囊,Rigidbody我使用加力将其从左向右移动,并限制速度以限制速度。

我正在尝试在 DOTS 上“冻结特定旋转”。

如果没有 DOTS,就会有 Unity 的“正常”方式来约束Rigidbody位置和旋转。

在此处输入图像描述

但是如果我们使用 DOTS,我就不能使用RigidbodyDOTS PhysicsBody,因为我没有找到任何方法来冻结/限制某些旋转。

如何PhysicsBody在 DOTS 中限制 a 的旋转?