Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 BennyXUNITY · Jan 16, 2021 at 03:15 AM · classesinterfaceassembliesreference assemblies

accessing a class by interface requries reference to other unrelated interface's assembly

Hey, been having some weirdness in my code, I think I get where the problem is but I wanted some clarification.

I have 2 separate classes and 2 interfaces in a few different assemblies.

FightingText, which is in the "fightlogic" assembly

Creature, which is in the "StatBased" Assembly

IreturnPronouns, an interface which is defined in the "TextLogic" Assembly

and ItakeDamage, an interface defined in "InteractionInterfaces" Assembly

to quickly explain how they are implemented:

 public class Creature : IreturnPronouns, ItakeDamage
 
 public class FightingText{
    function1(Creature c, ItakeDamage victim)
    function2(Creatrure c1, Creature c2)
 }

fightlogic has a reference to StatBased and InteractionInterfaces

StatBased has a reference to both interfaces' Assembly.

When Programming a function that has the signature of function1 (no body yet) I noticed, that it was throwing the exception:

The type IreturnPronouns is defined in an assembly that is not referenced. You must add a reference to assembly

Granted, fightlogic does not reference TextLogic, so it doesn't know IreturnPronouns, but in this case I am not using IreturnPronouns, I only require ItakeDamage. And when I changed the signature to the one described above as function2 it does not throw the error anymore. This confuses me. Why is IreturnPronouns a problem here? As far as I understand TextLogic wants to use interfaces inside of Creature but cannot access IreturnPronouns, since they are not in the same assembly.

But in this case when using creature it doesn't throw the error unless I use the function provided by the interface and when using the interface that is completely unrelated to IreturnPronouns it throws the Error.

Can you guys help me understand this? Is this kinda remote access even good practice? My assembly definiton references are always one way only, never circular, so I thought I was clear on how to correctly use them, but the info I can find on them and understand is quite scarce, so I may be using them wrong.

Any advice?

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

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

111 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

Related Questions

storing scripts that implements an interface 0 Answers

Adding assembly reference in visual studio causes error in unity 0 Answers

How to carry List's and Vector3's to other classes? Interfaces don't work? 4 Answers

Class derivation problem 1 Answer

How to choose base class to make Inherit C# 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