Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[SOLVED] IConvertGameObjectToEntity not found

Discussion in 'Entity Component System' started by as3mbus, Aug 8, 2019.

  1. as3mbus

    as3mbus

    Joined:
    Dec 5, 2016
    Posts:
    71
    i am trying to mimic sample provided in github. but i can't reference IConvertGameObjectToEntity

    below is code i try to write

    using unity 2018.3.14f1
    with unity entities 0.0.12 - preview.24

    Code (CSharp):
    1. using System;
    2. using Unity.Entities;
    3. using UnityEngine;
    4.  
    5. public class PlayerAxisInput : MonoBehaviour, IConvertGameObjectToEntity
    6. { }
    7. class PlayerAxisInputSystem : ComponentSystem
    8. {
    9.     struct ReqComponent
    10.     {
    11.         public PlayerAxisInput axis;
    12.     }
    13.     protected override void OnUpdate()
    14.     {
    15.         var input = new Vector2(Input.GetAxis("Horizontal"), 0);
    16.         foreach (var e in GetEntities<ReqComponent>())
    17.         {
    18.             // e.axis.InputVector = input;
    19.         }
    20.     }
    21. }
    the convert haven't written yet. since i can't even reference interface i want
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    You're on a very old version of the entities package. You need to update Unity to 2019.x and get a newer version of the entities package.

    Entities now requires 2019.1+
     
  3. as3mbus

    as3mbus

    Joined:
    Dec 5, 2016
    Posts:
    71
    oof i see . i thought i could just easily use it as long as it provided in UPM
     
  4. elcionap

    elcionap

    Joined:
    Jan 11, 2016
    Posts:
    138
    The conversion pipeline was introduced after the 0.0.12-preview.24 and require Unity 2019.1 or newer. Also GetEntities was discontinued and removed in newer versions of the entities package.

    Unless you are trying to use DOTS on a project with frozen 2018.3 version, you should take a look in the sample

    []'s

    Edit: @tertle was faster
     
  5. as3mbus

    as3mbus

    Joined:
    Dec 5, 2016
    Posts:
    71
    thankfully i just only just started trying it out. well thanks anyway
     
  6. as3mbus

    as3mbus

    Joined:
    Dec 5, 2016
    Posts:
    71
    So i just downloaded 2019.1.13f1 from unity hub and trying to just hotplug my mostly 2018 empty project. it doesnt seems to fetch up iconvertgameobjecttoentity even though i have already removed and re installed it. including removing and adding reference for assembly definition
     
  7. elcionap

    elcionap

    Joined:
    Jan 11, 2016
    Posts:
    138
    What the version after updating the Entities package? Should be preview-0.1.1.
    You should also install the Hybrid Render package otherwise you will need your own DOTS render system.

    []'s
     
  8. as3mbus

    as3mbus

    Joined:
    Dec 5, 2016
    Posts:
    71
    it is preview-0.1.1.
    also installed hybrid render package. but still i can't seem to reference it.

    Edit :
    so i found out that removing folder .asmdef, solved my issue. which mean i havent referenced unity entities properly, asmdef. is there any other asmdef i needed to reference in order to use IConvertGameObjectToEntity ?

    below is .asmdef for folder files resides in
    Code (json):
    1. {
    2.     "name": "Source",
    3.     "references": [
    4.         "Unity.Entities"
    5.     ],
    6.     "optionalUnityReferences": [],
    7.     "includePlatforms": [],
    8.     "excludePlatforms": [],
    9.     "allowUnsafeCode": false,
    10.     "overrideReferences": false,
    11.     "precompiledReferences": [],
    12.     "autoReferenced": true,
    13.     "defineConstraints": [],
    14.     "versionDefines": []
    15. }
     
    Last edited: Aug 9, 2019
  9. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    IConvertGameObjectToEntity is in Unity.Entities.Hybrid

    Tip: Even if you don't have the correct package referenced and while you can't add the reference via the IDE (Unity will still throw an error and as soon as project is recreated it'll be removed) it is often smart enough to know what to reference

    upload_2019-8-9_12-7-16.png

    Then you can just manually add it to the asmdef. This makes it pretty easy to find what you need to add.
     
    Last edited: Aug 9, 2019
    Ghosthowl and ThinhHB like this.
  10. as3mbus

    as3mbus

    Joined:
    Dec 5, 2016
    Posts:
    71
    ah finally got it running. no wonder i can't find iconvertgameobjecttoentity even through file search. file name doesnt even using I prefix.

    now i feel really silly. thankyou so much for the help
     
  11. as3mbus

    as3mbus

    Joined:
    Dec 5, 2016
    Posts:
    71
    unfortunately vscode doesn't seems able to do those tips. :(
     
  12. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    Unfortunately that's the difference between a code editor and an integrated development environment

    I assume you're on MacOS if you're using VSCode.
    I highly recommend Rider for Unity development these days as it just has a lot more support (though I haven't tried MacOS version but I'd assume it's the same). If you happen to be a student it's also free.
     
  13. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    Yep is the same as on Win, I use Rider on mac and Win, only annoying difference - hotkeys :) Always forgot some hotkeys or mix them in my mind :D
     
  14. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,085
    Very confusing that it's in Unity.Entities.Hybrid asmdef but namespace is Unity.Entities. Wouldn't have to google it if it was split. Similar issue with Unity.Collections and NativeStrings.
     
    Ghosthowl likes this.