Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

New SubScene & ConvertToEntity workflows

Discussion in 'Data Oriented Technology Stack' started by Joachim_Ante, Mar 4, 2019.

  1. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    1,534
    You have to build using that asset. When you open the the build settings file, it should show build option on the top in the inspector. If you hit the build button on the old build dialog, you are still on the old system.
     
  2. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,155
    is there a recommended way to load and convert a set of prefabs to be created as prefab entities? I create my own solution (using IConvertGameObjectToEntity and IDeclareReferencedPrefabs), but it still needs to rely on the ConvertGameObjectHierarchy method. I wonder if there is a way to create a subscene and serialise prefabs without need to convert them (so that I can also remove the load of the addressables as well) @5argon maybe you know?
     
    Last edited: Feb 9, 2020
  3. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    272
    Is it possible to have multiple Monobehaviours of the same type attached to a GameObject which is converted? In my system I want to have multiple behaviours (so they can be easily configured in the inspector etc) and then in the
    IConvertGameObjectToEntity
    method they will all be converted to entries in a single buffer on the entity.

    As far as I can see this is impossible to do just because the ConvertToEntity behaviour checks for duplicate behaviours and refuses to convert the entire object (even though there's no actual conversion problem here). Is this some way to simply disable this check?
     
  4. L2GX

    L2GX

    Joined:
    Aug 19, 2016
    Posts:
    40
    I just went and switched my next game over from dots to pure mono.
    I was still using World.Active and now I realised that I’d need a complete new way to transfer game objects to entities, and that there was no guarantee that even that new way would remain functional until release.
    If the samples project was updated and working it’d be a bummer but surmountable.
    Instead we have the new FPS demo that tells you it’s not stable up front...
    So, maybe create a new samples project when there’s enough stability one could swing a release?
     
  5. vestigial

    vestigial

    Joined:
    May 9, 2015
    Posts:
    152
    I want to send some appreciation to the team at Unity behind [GenerateAuthoringComponent]. I'm snooping around the Entities ILPostProcessor and it seems like a lot of cognitive effort and expertise went into crunching down the functionality into the attribute we can just apply.

    I do have a question, I'm getting ready to ask an asset developer if they'll support DOTS, and the generated code aspect (Entities.ForEach job generation in particular) seems like it will be non-trivial. Does anyone know if [GenerateAuthoringComponent] is pretty much how its going to be for Entities 1.0 ? If it was just generating .cs files it'd be one thing, but from what I can tell its doing some kind of in-memory assembly stuff, which is way beyond me. I'd hate to ask them to add support for codegen classes, if something easier is coming down the pipe.

    EDIT: Actually the solution was easier, just putting the ECS code alongside an asmdef file, so the code gets generated into a DLL which the asset is capable of interacting with.
     
    Last edited: Mar 8, 2020
    cultureulterior likes this.
  6. CWatsonT2

    CWatsonT2

    Joined:
    Jan 9, 2019
    Posts:
    54
    I'm trying to build for android using the hybrid renderer and I'm getting the error: "No run step provided for AndroidHybrid." when I try to build and run from my android build asset. I'm also not seeing the subscene objects show on the build. Are there any additional steps I'm missing? I tried the sample files and I can see those when they are built to the device but I haven't been able to figure out what is different between the two projects.

    Edit: What's with the assembly definition files? Do I need those. It's one of the things the demo project has that I don't.
     
    Last edited: Mar 4, 2020
  7. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    110
    This works for me (on
    2019.3.3f1
    ):
    upload_2020-3-4_13-41-35.png
     
  8. CWatsonT2

    CWatsonT2

    Joined:
    Jan 9, 2019
    Posts:
    54
    I appreciate that. My settings appear to be the same but I'm still getting the error:

    Run Android-Build failed.
    No run step provided for AndroidHybrid.

    Anyone know what that means?

    UPDATE: It seems it might have something to do with the BuildPipeline but I can't find any documentation about what that is or find it in the ECSSamples. Can anyone help?

    Updated Update: I added the RunStepNotImplemented to the androidHybrid build pipeline asset and updated the hybrid renderer package to 0.3.5 and now it's building.
     
    Last edited: Mar 6, 2020
  9. aveakrause

    aveakrause

    Joined:
    Oct 3, 2018
    Posts:
    21
    Subscene workflow is still TOTALLY broken.
    While a subscene is open, I can see that my component data is properly being added to my entities. When I close that subscene some of my component data is just plain out missing.

    BRING BACK THE FORCE CACHE RELOAD. WE REQUIRE IT TO FIX THESE ERRORS.
     
    Tunkali, filod and e199 like this.
  10. CWatsonT2

    CWatsonT2

    Joined:
    Jan 9, 2019
    Posts:
    54
    My results when using subscenes for VR on the Quest weren't good. I went from 30FPS without it to 10FPS with 1 subscene. I've abandoned entity conversion for now. I was hoping this would give me the performance boost I needed but no luck.
     
  11. LazyGameDevZA

    LazyGameDevZA

    Joined:
    Nov 10, 2016
    Posts:
    125
    @CWatsonT2 have you profiled why precisely this is happening?
     
  12. CWatsonT2

    CWatsonT2

    Joined:
    Jan 9, 2019
    Posts:
    54
    Not really. If I run it via the link cable and then profile it it runs amazingly fast. It only chokes when I build it onto the quest. I didn't profile that beyond watching the fps crash. Then I reverted my project to pre-hyrbid because I've already spent too much time on it.
     
  13. LazyGameDevZA

    LazyGameDevZA

    Joined:
    Nov 10, 2016
    Posts:
    125
    Unfortunately without any actual profiling it's hard to tell if the build process is being run correctly. With the conversion workflow there's bound to be performance spikes if entities get constructed through instantiating prefabs, but it doesn't sound like this is your issue. With the link cable, my understanding is that it's actually not building to the Quest and rather running the build on your computer and streaming data to- and from the Quest. It could be that the build for the Quest isn't correctly compiling the subscenes which could be the root of the issue.
     
  14. tarahugger

    tarahugger

    Joined:
    Jul 18, 2014
    Posts:
    128
    Getting these warnings after creating SubScenes; seems like a bug as these won't be used like regular scenes?

    Code (CSharp):
    1. Your current multi-scene setup has inconsistent Lighting settings which may lead to different lighting when loading scenes individually or in a different order! Consider homogenizing the following:
    2. 1/3 scenes have Auto baking enabled.
    3. 2/3 scenes use different skyboxes.
    4.  
     
  15. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    272
    Question for the ECS Team: What is the workflow now for working with GameObjects from systems? One of the most useful workflows for me before was being able to attach GameObjectEntity and iterate over GameObjects. That way I could just work as normal with GameObjects and then I could migrate what really needed the performance over the entities representation.

    I'd really, really like to use the new SystemBase API in concert with GameObjects, because the Job.WithCode() would be incredible for pulling main logic off the main thread while still getting all the existing features/workflow of unity.
    eg:
    Code (CSharp):
    1. protected override void OnUpdate() {
    2.     Entities.ForEach((Transform transform, Rigidbody rigidbody) => {
    3.         // setup planet gravity job data
    4.     }).Run();
    5.  
    6.     Job.WithCode(() => {
    7.         // compute planetary gravities
    8.     }).Schedule();
    9.  
    10.     Entities.ForEach((Rigidbody rigidbody) => {
    11.         // apply gravities to rigidbodies
    12.     }).Run();
    13. }

    ECS currently lacks many core features and the conversion workflow requires lots of boilerplate just to get access to them on the gameobject side.

    I have to be honest this has been massively frustrating to try to figure out. I've tried writing tons of conversion systems, every single configuration I could think of for subscenes. But they all seem to make the assumption i'm making some tech demo where it's ok to just, drop 90% of the existing features in unity.

    ConvertAndInject seems like it would be for exactly this, but it just duplicates every component. Now you have two renderers, transforms, etc... I really don't get how that would ever be useful.

    If there is no workflow for querying gameobjects, can i request an option in the convert to entities dropdown that's just "Linked Entity" or something? I'm not going to drop all the features of existing unity, all my code is there already. I was loving getting to convert over bit by bit as needed, but this all or nothing approach is hellish to actually try to make things with.

    Anyway, if anybody knows of an actual solution i'd love to hear it.
     
  16. WAYN_Group

    WAYN_Group

    Joined:
    Mar 16, 2019
    Posts:
    237
    Hello I'm having an issue with a subscene.

    I have a custom auhtoring component that allow me to add a list of struct. When the authoring component is converted to an entity, the list of struct is stored in a IComponentData class that I then use to initialize some data at runtime.

    When the scene is opened in the editor (edit mode) everything work fine but when I close it I get this error :

    Error when processing 'AsyncLoadSceneJob(VirtualArtifacts/Extra/23/23319d88e2738c325162389e980f80b7.0.entities)': System.NullReferenceException: Object reference not set to an instance of an object
    at Unity.Entities.TypeManager.GetTypeInfo (System.Int32 typeIndex) [0x00001] in C:\Users\Marc HANICOT\Documents\GitHub\MGM\Library\PackageCache\com.unity.entities@0.9.1-preview.15\Unity.Entities\Types\TypeManager.cs:348
    at Unity.Entities.Serialization.SerializeUtility.DeserializeWorld (Unity.Entities.ExclusiveEntityTransaction manager, Unity.Entities.Serialization.BinaryReader reader, System.Object[] unityObjects) [0x00110] in C:\Users\Marc HANICOT\Documents\GitHub\MGM\Library\PackageCache\com.unity.entities@0.9.1-preview.15\Unity.Entities\Serialization\SerializeUtility.cs:82
    at Unity.Scenes.AsyncLoadSceneOperation+AsyncLoadSceneJob.Execute () [0x00057] in C:\Users\Marc HANICOT\Documents\GitHub\MGM\Library\PackageCache\com.unity.entities@0.9.1-preview.15\Unity.Scenes.Hybrid\AsyncLoadSceneOperation.cs:98
    UnityEngine.Debug:LogWarning(Object)
    Unity.Debug:LogWarning(String) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/Stubs/Unity/Debug.cs:15)
    Unity.Scenes.SceneSectionStreamingSystem:UpdateLoadOperation(AsyncLoadSceneOperation, World, Entity) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Scenes.Hybrid/SceneSectionStreamingSystem.cs:373)
    Unity.Scenes.SceneSectionStreamingSystem:processActiveStreams() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Scenes.Hybrid/SceneSectionStreamingSystem.cs:276)
    Unity.Scenes.SceneSectionStreamingSystem:OnUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Scenes.Hybrid/SceneSectionStreamingSystem.cs:480)
    Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystem.cs:108)
    Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:134)
    Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:114)
    Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystem.cs:108)
    Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:134)
    Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:114)
    Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystem.cs:108)
    Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ScriptBehaviourUpdateOrder.cs:200)

    Now all the data I need is in fact a list of list in that the form you'll see below. I found a workaround that make it work in build and with the scene closed in hte editor by adding a dummy int to the thing I store.

    The IComponentDataClass
    Code (CSharp):
    1. using System;
    2. using Wayn.Mgm.Events.Registry;
    3. using Unity.Entities;
    4. using System.Collections.Generic;
    5.  
    6. [Serializable]
    7. public class EffectComponentData : IComponentData
    8. {
    9.     public List<ISelfRegistringAuhtoringComponent> listOfManagedBuffer = new List<ISelfRegistringAuhtoringComponent> ();
    10. }
    11.  
    The element of the stored list in the IComponentDataClass :
    Code (CSharp):
    1. using Wayn.Mgm.Events;
    2. using System;
    3. using Wayn.Mgm.Events.Registry;
    4. using Unity.Entities;
    5. using System.Collections.Generic;
    6.  
    7. [Serializable]
    8. public class EffectComponentDataElement<ELEMENT, BUFFER> : ISelfRegistringAuhtoringComponent
    9.      where ELEMENT : IRegistryElement
    10.      where BUFFER : struct, IEffectReferenceBuffer
    11. {
    12.     //public int number; // Without this, the subscene fails to load
    13.  
    14.     public List<ELEMENT> elements;
    15.  
    16.     public EffectComponentDataElement()
    17.     {
    18.         elements = new List<ELEMENT>();
    19.         //number = elements.Count;
    20.     }
    21.     public EffectComponentDataElement(List<ELEMENT> elements)
    22.     {
    23.         this.elements = elements;
    24.     }
    25.  
    26.     public void Register(EntityCommandBuffer ecb, Entity entity)
    27.     {
    28.         var buffer = ecb.AddBuffer<BUFFER>(entity);
    29.         foreach (var effect in elements)
    30.         {
    31.             buffer.Add(new BUFFER() { EffectReference = EffectRegistry.Instance.AddEffect((IEffect)effect) });
    32.         }
    33.     }
    34. }
    35.  
    Is that a bug are can't we have only list as serialzed data in subscenes ?
     
  17. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    473
    Is it possible to create a subscene during the runtime (e.g. procedural generated scene) and serialize it, write it to disk and load it on the next run?
     
  18. lmml

    lmml

    Joined:
    May 2, 2020
    Posts:
    2
    Hi there, I was reading this thread and I think u could help me with my problem. I am working on a kind of plugin package for unity so i was wondering to convert certain gameobjects on entities to use ecs. But my problem is that i want to do that on editor and not on runtime so i was thinking that maybe subscenes were my solution but i dont know how to attach gameobjects to a subscene on editor via code. I hope u can understand me , the main idea is to get on editor certain entities from gameobjects. I am noob on DOTS so dont be so hard with me :)
     
  19. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    137
    Is there a way to predict the order of converted objects and components? I'm asking because I need some data before others to be able to properly initialize my entities. What are the best practices for data conversion?
     
  20. LazyGameDevZA

    LazyGameDevZA

    Joined:
    Nov 10, 2016
    Posts:
    125
    It seems what you might be describing is a custom conversion system. It's not too difficult to write one and I think there is mention in the documentation of how to do something like that. I'm assuming you have authoring components that push data into the EntityManager that you need for other components to be fully ordered. Having a conversion system you could then schedule it to run after the main conversion system, which should yield a state where you're able to handle the correct items as expected.
     
  21. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    137
    Yeah, that's the case. I found the option to manually call the conversion of an object. It will suffice I think.
     
unityunity