Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Convert Game Object to Entity

Discussion in 'Entity Component System' started by mati2762, Jun 12, 2022.

  1. mati2762

    mati2762

    Joined:
    Dec 26, 2017
    Posts:
    24
    Hi
    When I convert Gameobject to Entity, Unity creates a new object in my scene.
    When changing the scene, references to objects are lost and I get a lot of errors.

    Is it possible to create objects on the `DontDestroyOnLoad` scene ?

    This is my conversion script.
    Code (CSharp):
    1.    
    2. var resource = Resources.Load<GameObject>(path);
    3. var blobAsset = new BlobAssetStore();
    4.  
    5. GameObjectConversionSettings settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, blobAsset);
    6.  
    7. var prefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(resource, settings);
    8. blobsAssetStore.Add(blobAsset);
    9.  return prefab;
    10.  
     
  2. mati2762

    mati2762

    Joined:
    Dec 26, 2017
    Posts:
    24
    I found a problem in ecs 0.50 and I don't know how to fix it.

    Play mode


    This item has not been destroyed and from what I see it is related to Hybrid Renderer V2
     
    Last edited: Jun 12, 2022
  3. mati2762

    mati2762

    Joined:
    Dec 26, 2017
    Posts:
    24
    How can i add CompanionLink component to my gameObject ?
     
  4. ThatDan123

    ThatDan123

    Joined:
    Feb 15, 2020
    Posts:
    11