Search Unity

Using Jobs inside GameObjectConversionSystem

Discussion in 'Entity Component System' started by RoughSpaghetti3211, Sep 29, 2019.

  1. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Wondering if I should be using Jobs in my GameObjectConversionSystem. Have not seen anyone do this is there a reason for that?
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    I can't see why a job would not work, but why would you need it?

    If your entity conversion is that expensive that even with the overhead a job is needed to optimise something is going really wrong. It doesn't make a lot of sense to me. GameObjectConversionSystem is converting a MonoBehaviour which you can't use in a job so are you copied components from a collection of MB into arrays then passing these to a job then copying them back to components?

    I suspect what you're trying to do should probably be an editor script or within a monobehaviour validation and then just copied to the entity in the conversion because I doubt you're doing this at runtime? More likely in a subscene.
     
    Last edited: Sep 29, 2019
  3. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,270
    Blob generation is a common use case. See BaseShapeConversionSystem.cs in Unity.Physics for an example.
     
  4. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Im running into this because I can only create an additional entity one at a time. Remember my crazy conversion where I made an entity per vertex ? it for that. Problem is there is no real data in the gameObject just what shape to generate. I found if I do this in a separate system it become really hard to keep in sync with live link so Im trying to keep it all in the GameObjCoversionSys.
     
  5. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Will check it out thanks
     
  6. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    That's kind of my point. You're doing this weird procedural generation in game object conversion. Does that really seem like the right location to do it?

    You've had half a dozen posts detailing the problems your running into attempting this but from my outside perspective to me actual problem is just that you shouldn't be doing this.

    Why not just store the data in the scene rather than generate it every conversion. From what I can tell, it's not even dynamic.
     
    Last edited: Sep 30, 2019
  7. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Originally i though I could get away from it being dynamic but I quickly ran into limitations. I will keep exploring different option and hopefully find a good solution. If anything ill keep learning as I go.