Search Unity

Official Samples

Discussion in 'Entity Component System' started by MartinGram, Mar 20, 2018.

  1. Micz84

    Micz84

    Joined:
    Jul 21, 2012
    Posts:
    451
    I have an issue with samples and beta 13. None of the examples work I get several errors similar to this:

    C:/ProgramData/Unity/cache/packages/staging-packages.unity.com/com.unity.collections@0.0.8/Unity.Collections/NativeHashMap.cs(794,14): error CS0246: The type or namespace name `NativeSetThreadIndex' could not be found. Are you missing an assembly reference?
     
  2. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Beta 13 don't support ecs at the moment
     
  3. tbg10101_

    tbg10101_

    Joined:
    Mar 13, 2011
    Posts:
    192
    Will Beta 14?
     
  4. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Yes, they merged it into the master branch
     
  5. FROS7

    FROS7

    Joined:
    Apr 8, 2015
    Posts:
    26
    Any timeframe on beta 14?? Im itching to try it out
     
  6. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    MadeFromPolygons and Krajca like this.
  7. PendingFox

    PendingFox

    Joined:
    Jan 15, 2017
    Posts:
    42
    Is there a way to assign Mesh.vertices using jobs? Not just calculate the vertices but assign... this would speed up the mesh generation a ton.
     
    H-Fly likes this.
  8. andywatts

    andywatts

    Joined:
    Sep 19, 2015
    Posts:
    112
    Not possible afaik.
    My understanding is MeshFilter and MeshRenderer currently only exist in MonoBehavior land.

    I'm following this pattern.
    1. Before calling job, create NativeArrays for verts, uvs, and triangles.
    2. Pass these to the job and have job populate.
    3. After job completes, read values to managed arrays and update mesh object.
    4. Dispose of the NativeArrays
     
  9. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982
    You could create the mesh and use Graphics.DrawMesh to draw it or the instanced version of that. You wouldnt need a mesh filter then or mesh renderer.
     
  10. korzen303

    korzen303

    Joined:
    Oct 2, 2012
    Posts:
    223
  11. Coed

    Coed

    Joined:
    Feb 18, 2016
    Posts:
    13
    Hello,
    just downloaded version 2018.1.0f1 (release candidate) and when I open Sample project I get DllNotFound exception. It can't find burst-llvm.dll file, but on 2018.1.0b12 everything is just fine, this Dll is on this path too. The RC version doesn't support Burst at this point or something like that?
     

    Attached Files:

  12. henrikpAtUnity

    henrikpAtUnity

    Unity Technologies

    Joined:
    Jan 6, 2017
    Posts:
    37
    We released a new update to the samples repository and our packages today.
    So now you can use the latest 2018.1 and latest 2018.2 beta Unity releases. No more custom builds required.
     
    recursive, FROS7 and elbows like this.
  13. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982
    Can we please get some comments on things that are meant to be "samples". Dumping mostly uncommented code in a repo with nothing to explain why lines are done, isnt really that useful for learning for novices.

    Also having to navigate from the code to a doc every line is annoying, for simple things that should have been comments from the get go.

    This is a new system guys, you really need to comment it, and I would have thought that would be common sense.
     
  14. mike_acton

    mike_acton

    Unity Technologies

    Joined:
    Nov 21, 2017
    Posts:
    110
    > an we please get some comments on things that are meant to be "samples".

    You can expect that we'll comment things up appropriately for the expected audience at some point before we actually release.
     
  15. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982
    Great thankyou :)
     
  16. hummer_4x4

    hummer_4x4

    Joined:
    Feb 3, 2013
    Posts:
    25
    I add GameObjectEntity, how add my script to "Used By Systems" ?
     
  17. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    If your object has an GameObjectEntity component attached, just
    write a system that handles some of the attached components.

    Thats it.
     
  18. Rs

    Rs

    Joined:
    Aug 14, 2012
    Posts:
    74
    I'm having a hard time to open projects that include ECS packages. I had the Samples working on my machine (Windows 10/64) then I tried to create my own project but when it starts importing the dependencies included in the manifest.json file. When I did that, it got stuck on Compiling Assembly Definition Files Scripts. Weirdly, now even the official Samples project will do the same thing. Force quitting is the only thing I can do.

    I tried with Unity 2018.1.0b4, 2018.1.0b12, 2018.2.b
    plus I tried already to
    • clear Library, Temp, obj folder as well as all project files (sln, csproj)
    • clear all Unity caches in Unity's AppData folder
    • Leave it there for an hour or more
    At the very end of Unity's log file there's this which I'm sure it's related, is it?

    Code (CSharp):
    1. - Starting compile Library/ScriptAssemblies/Unity.PackageManagerUI.Editor.dll
    2. - Starting compile Library/ScriptAssemblies/UnityEditor.StandardEvents.dll
    3. - Starting compile Library/ScriptAssemblies/NativeCounter.dll
    4. - Starting compile Library/ScriptAssemblies/Unity.Mathematics.dll
    5. - Starting compile Library/ScriptAssemblies/Unity.Properties.dll
    6. - Starting compile Library/ScriptAssemblies/Unity.Burst.dll
    7. (0,0): Unable to start the incremental compiler service:System.Exception: Subscribe exception: EAGAIN(11): Resource temporarily unavailable
    8. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    9. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    10. UnityEngine.Logger:Log(LogType, Object)
    11. UnityEngine.Debug:LogError(Object)
    12. UnityEditor.Compilation.UnityLog:Error(String, String, Int32, Int32)
    13. UnityEditor.Compilation.CompilerLog:MessageInternal(LogTarget, MessageOutput, MessageOutput, String, String, Int32, Int32)
    14. UnityEditor.Compilation.CompilerLog:Error(LogTarget, String, String, Int32, Int32)
    15. UnityEditor.Compilation.CompilerLog:Error(String, String, Int32, Int32)
    16. UnityEditor.Compilation.CompilerLog:Error(String, String)
    17. UnityEditor.Compilation.CompilerLog:Error(String)
    18. UnityEditor.Compilation.CompilerConnection:CreateIncrementalCompilerService(Int32)
    19. UnityEditor.Compilation.CompilerConnection:CreateIncrementalCompilerService()
    20. UnityEditor.Compilation.RoslynIncrementalCompiler:InvokeCompiler(String[], OnCompilerMessage, OnCompilationDone)
    21. UnityEditor.Compilation.<>c__DisplayClass5_0:<StartCompiler>b__0()
    22. System.Threading.ThreadHelper:ThreadStart_Context(Object)
    23. System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
    24. System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
    25. System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object)
    26. System.Threading.ThreadHelper:ThreadStart()
    The trouble seems to be concerning the incremental compiler but where do I go from here?
    Any help would be appreciated.
     
    Last edited: Jun 4, 2018
  19. ScottPeal

    ScottPeal

    Joined:
    Jan 14, 2013
    Posts:
    61
    Got ECS running on 2018.2.0b7 fine. FYI, when upgrading TextMeshPro to 1.3.0 via package manager there are 173 bugs. Not sure if that is ECS related or not. Seems to be related to a namespace issue in the new TMP package. Just putting here for FYI.
     
  20. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    OK In the Pure TwinStickShooter example what bit of code moves the enemy ships or for that matter the missiles as the only position changing code I can find belongs to the PlayerMoveSystem?
     
  21. dt665m

    dt665m

    Joined:
    Aug 15, 2015
    Posts:
    11
    Unity.Transforms2D.MoveFoward2DSystem. It's built in, and without looking at the code, my guess is it acts on a certain combination/archetype of Unity.Transforms2D ComponentData.
     
  22. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Thank you is there documentation for this?

    What about moving in a none forward direction e.g. sideways?
     
  23. dt665m

    dt665m

    Joined:
    Aug 15, 2015
    Posts:
    11
    Documentation is sparse. You can look at the code since it's open source. I haven't messed with any of the built in transform components yet but my guess is it has a heading component that is a vector in the direction to move in. You can probably hook your own system before the MoveForward2DSystem updates and modify the heading yourself if you want things to turn. The move system is probably discrete based on Delta time.
     
  24. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    So is there also a hidden RenderingSystem that takes the heading and position and draws the objects?

    Can I overload these systems with new behaviour e.g. wrap a turn left move then turn right into the MoveForward2DSystem or disable it?
     
  25. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    best is to look at the source code - there are posts here on where to find it.

    It is a bit unfortunate that the template components and systems are packed together with the source code. In my view, it would be better if those would be part of the individual project scripts...but again, it's an early version and it is as it is...
     
    Spy-Shifty likes this.
  26. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    It'd be good if it was somehow possible for VS/VSCode/Rider to include the package files and assemblies as projects in the solution view. This is probably easier said than done, but at least the code and other package contents are visible in the editor now.
     
  27. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    I am not very active at the moment and exclusively use SI3 (script inspector) after they discontinued monodev (mac). I could just click on the script of a “build in” ecs component and it would open it in unity, from there open containing folder and I am in the source folder. This is how I discovered it first.

    If I would start something serious in ecs, I would copy all build in components and systems into my project and only use those (manually copy over with new ecs releases). I like to have all things in one place. ;)
     
  28. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    You can technically do this now, it's currently the only way to use the new InputSystem preview package:
    https://github.com/UnityTechnologies/InputSystem
    If you copy the packages manually they'll show up as "Embedded" in the package manager. I haven't tested this with any package other than InputSystem, however.
     
  29. floboc

    floboc

    Joined:
    Oct 31, 2017
    Posts:
    91
    Did you solve this issue ?
    I just move from the frist beta release of ECS to the official 2018.1 release, and mono.exe keeps crashing, sometimes at the startup (same step as you) sometime after a random duration.I tried to delete all temp, obj, Library folders, vs solutions, etc. nothing works :(
     
  30. GT500

    GT500

    Joined:
    Apr 24, 2015
    Posts:
    8
    Any chance of getting access to the sample code used in the tutorial by Unity here?

     
  31. xenonsin

    xenonsin

    Joined:
    Dec 12, 2013
    Posts:
    20
  32. GerodruS

    GerodruS

    Joined:
    Aug 3, 2015
    Posts:
    7
    Just had a look at the samples. It was very interesting, but now I have a couple of questions:
    1. Profiler/Memory is showing some periodical gc allocations spikes (~100Kb at TwoStickPure, for example), but I can not see its origin at Profiler/CPU. What is it? Some allocations within native code?
    2. What about drawcalls and batching? Why every single instance (very simple objects) need its own drawcall? It's working at TwoStickPure, but completely broken at GalacticConquest and GravityDemo projects.
    I'm using Unity 2018.2.0f2.
     
  33. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Have you seen examples that do what you specified as of July 17, 2018? I'm still trying to search for them.
     
  34. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    Is it possible to have a very well documented simple sample?

    Like a sample project that only pops/depops cubes by tens of thousands with random textures and contains code comments explaining why each class/property is written as such?

    So far, the sample i saw were either too complex to begin with or not having enough comments to understands parts of it, which in turn makes it harder to understand the whole.
     
  35. Dawdlebird

    Dawdlebird

    Joined:
    Apr 22, 2013
    Posts:
    88
    I'm trying to have a look at those twin stick shooter examples using unity 2018.2.0f2, but I keep getting the error:
    "Copying assembly from directory Temp to Library/ScriptAssemblies failed". Having a look at the other examples give me the same error actually, though they did work in an older version of unity. Any chance these examples will get an upgrade to make them compatible with 2018.2?
     
  36. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Just open the project, then save project, then close Unity, then finally reopen the project.
     
  37. Dawdlebird

    Dawdlebird

    Joined:
    Apr 22, 2013
    Posts:
    88
    Ah, thanks for the reply, I will try that
     
  38. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Actually, I retract my sentence. What you need to do is to go to Assets > Reimport All.

    This should actually do the trick. Then you save the project once the Unity editor restarts itself.
     
  39. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    When people are starving, you give them tools to reap the food, but do not tell them how to use the tools. Ppl should watch what your giving to the best.
     
  40. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,779
    Despe
    Desperate and determined people can figure it out.
    In our case early adopter. From which point, lots of info and solutions is emerging.

    Otherwise, you may wait forever. Is just like waiting to release product, until will satisfy you and no bugs having. Then realizing, you never release it, because taking so long.

    Btw, where did you see hunger people been given tools to work things out? ^.^
     
    KwahuNashoba likes this.
  41. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    347
    Are there any samples with new features i.e. reactive system?
     
  42. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,779
  43. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,779
    Some samples seams are broken. At least on my Unity.
    Unity 2018.3.0b10 (has been rolled back to 0b9)

    Unity-Technologies/EntityComponentSystemSamples

    BoidExample crashes unity.
    Dungeons throws bunch of errors
    ArgumentException: It is not allowed to have two components of the same type on the same entity. (Static and Static)
    Unity.Entities.ArchetypeManager.AssertArchetypeComponents (Unity.Entities.ComponentTypeInArchetype* types, System.Int32 count) (at Library/PackageCache/com.unity.entities@0.0.12-preview.12/Unity.Entities/ArchetypeManager.cs:334)
    Unity.Entities.ArchetypeManager.GetOrCreateArchetypeInternal (Unity.Entities.ComponentTypeInArchetype* types, System.Int32 count, Unity.Entities.EntityGroupManager groupManager) (at Library/PackageCache/com.unity.entities@0.0.12-preview.12/Unity.Entities/ArchetypeManager.cs:400)
    Unity.Entities.ArchetypeManager.GetOrCreateArchetype (Unity.Entities.ComponentTypeInArchetype* types, System.Int32 count, Unity.Entities.EntityGroupManager groupManager) (at Library/PackageCache/com.unity.entities@0.0.12-preview.12/Unity.Entities/ArchetypeManager.cs:367)
    Unity.Entities.EntityDataManager.AddComponent (Unity.Entities.Entity entity, Unity.Entities.ComponentType type, Unity.Entities.ArchetypeManager archetypeManager, Unity.Entities.SharedComponentDataManager sharedComponentDataManager, Unity.Entities.EntityGroupManager groupManager, Unity.Entities.ComponentTypeInArchetype* componentTypeInArchetypeArray) (at Library/PackageCache/com.unity.entities@0.0.12-preview.12/Unity.Entities/EntityDataManager.cs:545)
    Unity.Entities.EntityManager.AddComponent (Unity.Entities.Entity entity, Unity.Entities.ComponentType type) (at Library/PackageCache/com.unity.entities@0.0.12-preview.12/Unity.Entities/EntityManager.cs:406)
    Unity.Entities.EntityManager.AddComponentData[T] (Unity.Entities.Entity entity, T componentData) (at Library/PackageCache/com.unity.entities@0.0.12-preview.12/Unity.Entities/EntityManager.cs:432)
    Samples.Dungeon.First.BoardSystem.InstantiateFromArray (Unity.Collections.NativeArray`1[T] prefabs, System.Single xCoord, System.Single yCoord, Unity.Entities.Entity parent) (at Assets/Dungeon/Scripts/BoardSystem.cs:542)
    Samples.Dungeon.First.BoardSystem.InstantiateTiles (Samples.Dungeon.First.Board board, Unity.Collections.NativeArray`1[T] tiles, System.Int32 tilesStride, Unity.Entities.Entity parent) (at Assets/Dungeon/Scripts/BoardSystem.cs:521)
    Samples.Dungeon.First.BoardSystem.OnUpdate () (at Assets/Dungeon/Scripts/BoardSystem.cs:276)
    Unity.Entities.ComponentSystem.InternalUpdate () (at Library/PackageCache/com.unity.entities@0.0.12-preview.12/Unity.Entities/ComponentSystem.cs:324)
    Unity.Entities.ScriptBehaviourManager.Update () (at Library/PackageCache/com.unity.entities@0.0.12-preview.12/Unity.Entities/ScriptBehaviourManager.cs:82)
    Unity.Entities.ScriptBehaviourUpdateOrder+DummyDelagateWrapper.TriggerUpdate () (at Library/PackageCache/com.unity.entities@0.0.12-preview.12/Unity.Entities/ScriptBehaviourUpdateOrder.cs:703)

    Other samples seams working.

    Entities 0.0.12-preview 12
    Burst 0.2.4-preview.37
    IncrementalCompiler 0.0.42-preview.24
    Jobs 0.0.7-Preview.5
    Mathematics 0.0.12.preview.19
     
  44. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,779
  45. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    I updated this to the latest 2019.1 alpha + ECS + PP here:
    https://github.com/0lento/Voxelman/tree/2019.1-update

    Worth mentioning that there's really nothing special here. If you want to run the original project on latest ECS on 2018.2 or 2018.3, just grab the Assets/ECS changes from my 2019.1 branch, update to Entities 0.0.12-preview.21 -package, change the missing script from scene to com.unity.entities/Unity.Transforms/PositionComponent and you're set. Reason to port it to 2019.1 directly was that I just wanted to examine it running on bleeding edge Unity version.
     
    Last edited: Dec 6, 2018
    Antypodish likes this.
  46. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,779
    I forgot how cool Voxelman was to watch ;)

     
    florianhanke likes this.
  47. Deleted User

    Deleted User

    Guest

    I downloaded the samples yesterday and opened the project with 2018.3.0f2: everything works fine, no error messages.

    Are there tutorials related to these samples or are we left alone with deconstructing them? :)
     
  48. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,779
    At this stage I wouldn't be expecting any tutorials on samples. At least I am not aware of. Thing is, this sample evolves, getting updated every few iterations of ECS.

    So yes, you may be left to decompose them by self. At leat for now. However, look up both doc, and forum for relevant parts of code, for more info.
     
    Deleted User likes this.
  49. Micz84

    Micz84

    Joined:
    Jul 21, 2012
    Posts:
    451
    I have a question about the boid example. In MergeCell job of BoidSystem there is line in ExecuteFirst method:

    var position = cellSeparation[index].Value / cellCount[index];

    cellCount[index] is increased in ExecuteNext method, so isn't it always 1 as it is initialized in MemSetNativeArray job?
     
  50. OleJuergensen

    OleJuergensen

    Joined:
    Mar 21, 2018
    Posts:
    11
    @Micz84 ExecuteFirst can be called multiple times with the same index, because the index is actually the value of the underlying multiHashMap, not the key. The 'First' in ExecuteFirst referes to the hash, which is determined by the key, not the value of the hashMap. The job can then encounter the same index twice, but with a different key(and thus hash), so it calls ExecuteFirst. To see this, check out NativeHashMap.cs

    I have a question, too, about the Cube Example (oh dear...)

    when I run the latest version of the HelloCureRotationSpeed Sample scene, the cubes rotation keeps being reset frequently to (0f, 0,009999833f, 0f, 0,99995f), so it ends up in a jumpy rotation. I deactivated all systems except the HelloRotationSpeedSystem - still the same. How can I find out, where this reset happens. Why does it happen?

    thank you!