Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
1
Question by $$anonymous$$ · Jul 18, 2015 at 06:46 AM · assemblypythonrename

How do you rename Assembly-CSharp in a project?

I have a version 4.x project that uses IronPython so I can make python scene building scripts and an interactive python console work for my game. All this was working fine (even as an .exe) until I came to try it in the new version 5 of Unity. My build scripts were able to add MonoBehaviour components to dynamically created GameObjects using AddComponent("MyScriptComponent") but this usage has now been removed from the Unity 5 API.

I can use IronPython's generics syntax which looks like this: AddComponent[MyScriptComponent]() but I have to import the reference for the relevant assembly containing my script at the top of my Python build files. This works fine for any DLLs I've made with script components in them. The problem comes when I try to import the Assembly-CSharp.dll file for any C# script component files that reside in Unity's Assets folder. I can add the assembly reference at the top of my Python build script but then Python will not let me use: import Assembly-CSharp to load the module as it moans about the '-' sign in the name.

No amount of Python hackery seems to work despite trawling the web and trying anything I could find. All I really need to do is to get Unity/MonoDevelop to use a different name for the assembly such as AssemblyCSharp and all should work fine but I cannot seem to make it do this. I did try changing the options for the assembly via MonoDevelop so it renamed it and built it as a differently named assembly and whilst this seemed to work for loading the assembly into the clr, Python said it could not find the module afterwards.

My alternative approach is to make an extension method so I can still use the older, deprecated syntax for AddComponent.

Any thoughts anyone?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by meat5000 · Jul 18, 2015 at 06:49 AM

AddComponent(string), when called with a variable cannot be automatically updated to the generic version AddComponent< T>(). In such cases the API Updater will replace the call with a call to APIUpdaterRuntimeServices.AddComponent(). This method is meant to allow you to test your game in editor mode (they do a best effort to try to resolve the type at runtime) but it is not meant to be used in production, so it is an error to build a game with calls to such method). On platforms that support Type.GetType(string) you can try to use GetComponent(Type.GetType(typeName)) as a workaround.

http://docs.unity3d.com/Manual/UpgradeGuide5-Misc.html

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

2 People are following this question.

avatar image avatar image

Related Questions

in Unity 5, how can I get/set an asset's AssetBundle assignment via scripting? 1 Answer

Why does Boo not see namespaces from dlls? 1 Answer

Can't call custom Debug class (assembly issue?) 2 Answers

Editor class for Animation window 1 Answer

Is it legal to tamper in the Assembly file libunity.so? 2 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