Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question what do I use to replace GetEntity(gameobject) which is obsolete

Discussion in 'Entity Component System' started by MrMajorThorburn, Jan 25, 2024.

  1. MrMajorThorburn

    MrMajorThorburn

    Joined:
    Dec 15, 2014
    Posts:
    89
    I am trying to follow an oldish tutorial about ECS and come up to a problem I have not been able to find an answer to.
    I am using 2023.2 editor and Entities 1016 and need to add an entity derived from a game object that contains a reference to a prefab connected in the Inspector.
    The tutorial uses GetEntity but that is Obsolete so need an alternative,
    I have done some searching but keep getting stuck with out of date solutions.

    Can someone give me a simple example to replace this line of code
    TombstonePrefab = GetEntity(authoring.TombstonePrefab)
    in this sample

    AddComponent(entity, new GraveyardProperties
    {
    FieldDimensions = authoring.FieldDimensions,
    NumberTombstonesToSpawn = authoring.NumberTombstonesToSpawn,
    ZombieSpawnRate = authoring.ZombieSpawnRate,
    TombstonePrefab = GetEntity(authoring.TombstonePrefab) // this is the error line
    });


    where the source TombstonePrefab is defined in the parent class (authoring) as a GameObject
     
  2. Spy-Master

    Spy-Master

    Joined:
    Aug 4, 2022
    Posts:
    908
    "Entities 1016" is not a thing. You probably mean 1.0.16. You should refer to it this way.
    2023.2 can mean a number of editor versions. Be specific, like 2023.2.3f1.

    Did you read the message defined for the ObsoleteAttribute on the obsolete method? That message tells you what to do.
     
    MrMajorThorburn likes this.
  3. MrMajorThorburn

    MrMajorThorburn

    Joined:
    Dec 15, 2014
    Posts:
    89
    Sorry, I did another read through and realised I had already got the flags to be able to get where I was so added them as the second parameter and the obsolete has gone away.
     
    Last edited: Jan 25, 2024