Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
3
Question by cchpackers1 · May 09, 2019 at 01:31 PM · errorscript.error message

cannot convert from 'Unity.Entities.Entity' to 'Unity.Entities.EntityQuery'

I get two errors when I am compiling the code and I cannot seem to figure out why, I am new to Entities so this is my attempt to try to figure them out.

Below is my code:

 public class BootStrap
 {
     public static EntityArchetype PlayerUnitArchType;
     private static Mesh cubeRenderer; //renderer for each of the entities you want to render in scene
     private static EntityManager entityManager;
 
     //need initialize and initialize with scene in bootstrap
     [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
     public static void Initialize()
     {
         //This method creates archetypes for entities we will spawn frequently in this game
         //Archetypes are optional but can speed up entity spawing substantially 
         entityManager = World.Active.EntityManager;//handels all entity manageing
 
         //archtype for things that are used multiple times
         PlayerUnitArchType = entityManager.CreateArchetype(typeof(Translation),
             typeof(Rotation),
             typeof(MoveSpeed),
             typeof(PlayerInputComponent) );
         
 
     }
     [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
     public static void InitializeWithScene()
     {
         cubeRenderer = GetLookFromPrototype("CubePrototype");//make cube prototype in scene
         StartRTSGame();
     }
 
     public static void StartRTSGame()
     {
         for (int i = 0; i< 3; i++)
         {
 
             Entity playerUnit = entityManager.CreateEntity(PlayerUnitArchType);
 
             //set pos .5 away from each other to give space 
             entityManager.SetComponentData(playerUnit, new Translation { Value = new float3(i * 5, 0.5f, 0) });
             //data that doesn't change often, genrally were render stuff goes
             entityManager.AddSharedComponentData(playerUnit, cubeRenderer);
         }
     }
     public static Mesh GetLookFromPrototype(string protoName)
     {
         var proto = GameObject.Find(protoName);
         var result = proto.GetComponent<RenderMesh>().mesh;
         //obect.Destroy(proto);
         return result;
 
     }

The two errors I get are below:

  1. ArgumentException: GetComponent requires that the requested component 'RenderMesh' derives from MonoBehaviour or Component or is an interface. UnityEngine.GameObject.GetComponent[T] ()

  2. Assets\RTS_ECS_Tutorial\Scripts\BootStrap.cs(50,50): error CS1503: Argument 1: cannot convert from 'Unity.Entities.Entity' to 'Unity.Entities.EntityQuery'

I am very new to ECS and am trying to learn it so any comments about my code would be appreciated.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hellium · May 09, 2019 at 01:32 PM 0
Share

The first error is caused by this line

      var result = proto.GetComponent<Render$$anonymous$$esh>().mesh;

It should be

      var result = proto.GetComponent<$$anonymous$$eshRenderer>().mesh;

The 2nd error however, is strange, because AddSharedComponentData accepts an Entity

 public void AddSharedComponentData<T>(Entity entity, T componentData)
 where T : struct, ISharedComponentData

https://docs.unity3d.com/Packages/com.unity.entities@0.0/api/Unity.Entities.Entity$$anonymous$$anager.html#Unity_Entities_Entity$$anonymous$$anager_AddSharedComponentData__1_Unity_Entities_Entity___0_

avatar image sampenguin · Sep 17, 2019 at 09:22 PM 0
Share

I'm having the same problem as your #2 error with entity$$anonymous$$anager.SetSharedComponentData(), which definitely has a form of (Entity, ComponentData) per docs and metadata, but it won't compile saying it can't convert it to an EntityQuery. It's like the compiler can't see the overloads... WTH??

avatar image shortwanabelaker · Oct 16, 2019 at 08:02 PM 0
Share

Any luck with #2?

avatar image Toylips · Nov 30, 2019 at 12:39 PM 0
Share

Same problem, even if I switch to the Unity.Entities.EntityQuery it says Argument 1: cannot convert from 'Unity.Entities.EntityQuery' to 'Unity.Entities.Entity' :)

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

215 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

"The associated script cannot be loaded." 0 Answers

Object reference not set to an instance of an object (c#) 0 Answers

Can't Add Script Behavior... 2 Answers

Can't add Orbital script - "The script needs to derive from MonoBehaviour!" 0 Answers

Getting error on lap counter script JS 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges