Search Unity

ExecuteAlways dead end with conversion

Discussion in 'Entity Component System' started by alexandre-fiset, Feb 16, 2020.

  1. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    715
    I have hit a wall with DOTS and wonder if there is any plan from Unity to fix it.

    Basically I am creating a system that render a canvas to a texture, and then applies it to some materials (in this case, on the pages of a notebook). In this scenario, I want to be able to build my book pages in edit mode.

    The problem is that the camera does not render anything if added to a subscene and my systems won't run on anything that is not in a subscene.

    Is there any plan to support ExecuteAlways on entities converted outside of subscenes?
     
  2. brunocoimbra

    brunocoimbra

    Joined:
    Sep 2, 2015
    Posts:
    679
  3. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    715
    Thanks for the very useful information!

    Unfortunately, it looks like Camera cannot be added with AddHybridComponent. It works for all other types I've tried such as Image, Canvas and RectTransform, but the camera is never added to the entity and consequently never renders...

    upload_2020-2-16_1-4-4.png
     
  4. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    I too had problems with cameras and companion gameobjects. It would be nice to get an official answer on the long term roadmap for them(companion/hybrid gameobjects), what with the warning and all.
     
  5. brunocoimbra

    brunocoimbra

    Joined:
    Sep 2, 2015
    Posts:
    679
    Oh, that's sad, never used with Camera, but I thought it would work. I wonder if there are any other components that don't work the same when using it as HybridComponents...
     
  6. Timboc

    Timboc

    Joined:
    Jun 22, 2015
    Posts:
    238
    My current understanding is that if you have a Subscene open and livelink enabled, there will be a World with systems being updated and ExecuteAlways should work.

    Outside of this you need to call:
    DefaultWorldInitialization.DefaultLazyEditModeInitialize();

    followed by
    EditorApplication.QueuePlayerLoopUpdate();
    (e.g. on Editor Update)
    But.. as ever, I could be out of date. I'd also value official Unity input here if there's a better approach.

    N.B. In my case I want to add specific systems to run at edit time so I do something along the lines of:
    Code (CSharp):
    1. DefaultWorldInitialization.DefaultLazyEditModeInitialize();
    2. var _TweenWorld = World.DefaultGameObjectInjectionWorld;
    3. List<System.Type> systems = UnityEditor.TypeCache.GetTypesDerivedFrom(typeof(MyComponentSystemBase));
    4. DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(_TweenWorld, systems);
    5. ScriptBehaviourUpdateOrder.UpdatePlayerLoop(_TweenWorld);
    Though I remember seeing some API that finds all systems with the ExecuteAlways attribute for example.
    Hope that helps.