Jump to content
  • Advertisement
Sign in to follow this  
dvds414

Game Won't Compile when Using my Manager?

This topic is 1825 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I am having this issue with a line of code claiming that I am referencing a different effect that is not basiceffect?

 

foreach (ModelMesh Mesh in Model.Meshes)
                foreach (BasicEffect ES in Mesh.Effects)
                    Textures[i++] = ES.Texture;

 

Those are the lines of code that fail for me, I have a manager that spawns 5 buildings and calls that texture loading method right there 5 times. For some reason though I get the error: Unable to cast object of type 'Microsoft.Xna.Framework.Graphics.Effect' to type 'Microsoft.Xna.Framework.Graphics.BasicEffect'.

 

Does anyone have a fix for this?

Share this post


Link to post
Share on other sites
Advertisement

You're trying to convert the property to a type its graph doesn't support so it bombs. This is done by first assigning an object of the type you want to extract to the property before you do your foreach.

 

Edit: Saw this was on compile. This is strange. With casting as long as your "box" gets bigger, and not smaller, it's fine. Do you have VS set to fail on warn?

Edited by hrmmm

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!