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 /
avatar image
0
Question by dansav · Jul 20, 2018 at 07:46 PM · dynamic

Error trying to use ExpandoObject in Unity 2018.1

I get an error when trying to use expandoObject with Unity 2018.1 free edition

 using System.Dynamic;
         dynamic MyDynamic = new System.Dynamic.ExpandoObject();
         MyDynamic.A = "A";

The error is in the line: MyDynamic.A="A";
Unexpected symbol `=' in class, struct, or interface member declaration using System.Dynamic;

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Nomenokes · Jul 20, 2018 at 08:08 PM

You need to have your code inside a class, which you do not have a declaration of. The compiler thinks that using System.Dynamic is your class declaration. For example:

 using System.Dynamic;
 
 public class Expander : MonoBehaviour {
      dynamic MyDynamic = new System.Dynamic.ExpandoObject();
      MyDynamic.A = "A";
 }

The class needs to be of the same name of the file that it's in. This class would need to have a file name of Expander.cs.


I'm not sure what ExpandoObject is, but the error is a compiler error with your code, not with ExpandoObject.

Comment
Add comment · Show 6 · Share
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 dansav · Jul 20, 2018 at 08:43 PM 0
Share

It was in a class like you suggested I just didn't include the code. I pasted your code example into a new cs file named Expander.cs and get the same error.

avatar image Nomenokes · Jul 20, 2018 at 10:40 PM 0
Share

Hmm. Can you post your entire class of code please? The compiler tends to be bad about where exactly the error is.

avatar image dansav Nomenokes · Jul 23, 2018 at 05:54 PM 0
Share
 using System.Dynamic;
 
 public class expander   : $$anonymous$$onoBehaviour {
 
     dynamic myEo = new ExpandoObject();
     myEo.a="a";
  }

avatar image MaxGuernseyIII dansav · Jul 23, 2018 at 05:56 PM 1
Share

...it needs to be in a method, too...

 public class foo {
   public void DoSomething() {
     dynamic myEo = new ExpandoObject();
     myEo.a="a";
   }
 }
Show more comments
avatar image
0

Answer by tomasofen · Sep 14, 2019 at 11:27 AM

dynamic "ExpandoObject" does not work on Unity as it is based on Mono, isn't it?

The last time i tried they could be declared, but failed when trying to modify their "dinamic" properties like:

myEo.a="a";

It would be great if someone tells me that i'm wrong and that this can be used Ö.Ö

Comment
Add comment · Share
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

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

90 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

Related Questions

What is the most efficient way to dynamically add a component, based on a string passed in. 1 Answer

Is it possible to have continuous collision detection with dynamic points on Edge Colliders? 0 Answers

Instantied GameObject Prefab doesn't have a height 0 Answers

Best way to dynamically assign a camera? 0 Answers

How to access the data in a list that save any class inside 1 Answer


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