Skip to content

Instantly share code, notes, and snippets.

@Arakade
Created October 22, 2018 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arakade/8849aba4bdf0e5383ab5ce8965bbeaf1 to your computer and use it in GitHub Desktop.
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)
/*
* 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 { }
}
/*
* 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 { }
}
@dimmduh
Copy link

dimmduh commented Dec 24, 2019

Is this a way to get access to internal Unity methods?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment