Created
October 22, 2018 21:07
-
-
Save Arakade/8849aba4bdf0e5383ab5ce8965bbeaf1 to your computer and use it in GitHub Desktop.
Friend assembly allows access to internals from different assembly! (for Unity Editors or unit tests and when using assembly definition files = .asmdefs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* File "MyInternalClass.cs" | |
* in "MyName" assembly (defined by a "MyName.asmdef"): | |
*/ | |
using System.Runtime.CompilerServices; | |
// Make this class available to its Unity PropertyDrawer despite being 'internal' | |
[assembly: InternalsVisibleTo("MyName_Editor")] | |
namespace my.name { | |
internal class MyInternalClass { } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* File "MyInternalClassPropertyDrawer.cs" (or unit test or whatever) | |
* in "MyName_Editor" assembly (defined by a "MyName_Editor.asmdef"): | |
*/ | |
using UnityEditor; | |
namespace my.name.editor { | |
[CustomPropertyDrawer(typeof(MyInternalClass))] | |
internal class MyInternalClassPropertyDrawer : PropertyDrawer { } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this a way to get access to internal Unity methods?