• Stars
    star
    100
  • Rank 330,398 (Top 7 %)
  • Language
    C#
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Roslyn compiler to access internals/privates for Unity. In other words, you can access to any internals/privates in other assemblies, without reflection. Let's say, "Open sesame!"

Open Sesame Compiler For Unity

⚠️ NOTE: This project has been integrated into CSharpCompilerSettingsForUnity. We are NOT continuing development in this repository. ⚠️





A custom Roslyn compiler and editor extension to access internals/privates for Unity.
In other words, you can access to any internals/privates in other assemblies, without reflection.

Let's say, "Open sesame!"

PRs Welcome

<< Description | Installation | Usage | Contributing >>

What's new? See changelog

Do you want to receive notifications for new releases? Watch this repo

Support me on GitHub!

become_a_sponsor_on_github





Description

Then Ali Baba climbed down and went to the door concealed among the bushes, and said, "Open, Sesame!" and it flew open.

This package allows to access to any internals/privates in other assemblies, without reflection.

For details about IgnoresAccessChecksToAttribute, see No InternalsVisibleTo, no problem – bypassing C# visibility rules with Roslyn.

Features

  • Easy to use
    • this package is out of the box.
  • Allow to access to any internal/private elements (types/members) in other assemblies, without reflection
    • Create instance
    • Get/set fields or properties
    • Call method
    • Create extension method that contains private access
    • etc.
  • Processes only AssemblyDefinitionFile you configured
  • Add/remove the scripting define symbols for each AssemblyDefinitionFiles
  • Support C#8
  • Support .Net 3.5, .Net 4.x and .Net Standard 2.0
  • dotnet is not required
  • Publish as dll
    • Published dll works without this package.
  • Portable mode
    • Without publishing, make the assembly available to access to internals/privates in other assemblies, even in projects that do not have this package installed.
    • The best option when distributing as a package.

NOTE: Unsupported Features

  • Set/get value into readonly field
    • Use reflection
  • IDE support





Installation

Requirement

  • Unity 2018.3 or later

Using OpenUPM

This package is available on OpenUPM. You can install it via openupm-cli.

openupm add com.coffee.open-sesame-compiler

Using Git

Find the manifest.json file in the Packages directory in your project and edit it to look like this:

{
  "dependencies": {
    "com.coffee.open-sesame-compiler": "https://github.com/mob-sakai/OpenSesameCompilerForUnity.git",
    ...
  },
}

To update the package, change suffix #{version} to the target version.

  • e.g. "com.coffee.open-sesame-compiler": "https://github.com/mob-sakai/OpenSesameCompilerForUnity.git#1.0.0",

Or, use UpmGitExtension to install and update the package.





Usage

  1. Select a AssemblyDefinitionFile in project view
  2. Configure setting for the assembly in inspector view:
    • Open Sesame: Use OpenSesameCompiler instead of default csc to compile this assembly. In other words, allow this assembly to access to internals/privates to other assemblies without reflection.
    • Settings: how/hide the detail settings for this assembly.
      • Modify Symbols: When compiling this assembly, add/remove semicolon separated symbols. Symbols starting with '!' will be removed.
        NOTE: This feature is available even when 'Open Sesame' is disabled
      • Portable Mode: Make this assembly available to access in internals/privates to other assemblies, even in projects that do not have Open Sesame Compiler package installed.
    • Publish: Publish this assembly as dll to the parent directory.
    • Help: Open help page on browser.
  3. Enjoy!





Demo

  1. Clone demo branch in this repo and open it with Unity 2018.3 or later
git clone -b demo https://github.com/mob-sakai/OpenSesameCompilerForUnity.git
  1. The project has some inaccessible compilation errors
  2. Do not worry, they are proper errors.
    The demo project access to internals/privates:
// EditorApplication.CallDelayed is an internal-static method in UnityEditor assembly.
EditorApplication.CallDelayed(() => Debug.Log("delayed"), 1);
  1. Select Assets/Tests/Coffee.OpenSesame.Test.asmdef in project view and activate 'Open Sesame' in inspector view
  2. Run all edit mode tests in test runner view (Windows > General > Test Runner).
    The compilation error is gone, but some tests that depend on symbols will not pass.
[Test]
public void DefineSymbols()
{
    const string log = "OSC_TEST is defined.";
    LogAssert.Expect(LogType.Log, log);
#if OSC_TEST // <- not defined!
    Debug.Log(log);
#endif
}

[Test]
public void RemoveSymbols()
{
    const string log = "TRACE is not defined.";
    LogAssert.Expect(LogType.Log, log);
#if !TRACE // <- defined automatically by Unity!
    Debug.Log(log);
#endif
}
  1. Enable symbols to modify scripting define symbols for this assembly.
    Then edit Modify Symbols to OSC_TEST;!TRACE. This means "add OSC_TEST symbol and remove TRACE symbol for this assembly."
  2. All tests pass!

For more details, see the article 1 (Japanese) and the article 2 (Japanese).





Contributing

Issues

Issues are very valuable to this project.

  • Ideas are a valuable source of contributions others can make
  • Problems show where this project is lacking
  • With a question you show where contributors can improve the user experience

Pull Requests

Pull requests are, a great way to get your ideas into this repository.
See CONTRIBUTING.md.

Support

This is an open source project that I am developing in my spare time.
If you like it, please support me.
With your support, I can spend more time on development. :)






License

  • MIT

Author

mob-sakai

See Also

Special Thanks

  • Special thanks to @pCYSl5EDgo, your ideas contributed to improve this package.

More Repositories

1

UIEffect

UIEffect is an effect component for uGUI element in Unity. Let's decorate your UI with effects!
C#
5,248
star
2

ParticleEffectForUGUI

Render particle effect in UnityUI(uGUI). Maskable, sortable, and no extra Camera/RenderTexture/Canvas.
C#
3,747
star
3

SoftMaskForUGUI

UI Soft Mask is a smooth masking component for Unity UI (uGUI) elements.
C#
1,778
star
4

UpmGitExtension

This package extends the UI of Unity Package Manager (UPM) for the packages installed from git repository.
C#
738
star
5

UnmaskForUGUI

A reverse masking solution for uGUI element in Unity.
C#
738
star
6

ShinyEffectForUGUI

Shiny effect of uGUI, which does not need mask or normal map.
C#
353
star
7

CSharpCompilerSettingsForUnity

Change the C# compiler (csc) used on your Unity project, as you like!
C#
274
star
8

GitDependencyResolverForUnity

This plugin resolves git url dependencies in the package for Unity Package Manager. You can use a git url as a package dependency!
C#
236
star
9

StaticBluredScreen

Non-realtime (=static) screen blur for Unity. Easy to use background for dialogs.
C#
182
star
10

MeshEffectForTextMeshPro

Mesh effect components for TextMeshPro in Unity.
C#
141
star
11

AtlasImage

AtlasImage is a graphic component use SpriteAtlas for uGUI. In addition, add useful sprite selector and border editor to the inspector.
C#
127
star
12

UIEffectSnapshot

Capture a screenshot with effect and display it. Light-weight, non-realtime, no-camera (and no-PostProcessingStack), but be effective enough. The captured snapshot can be used as a background for a UI panel.
C#
127
star
13

MirrorReflectionEffectForUGUI

A simple mirror reflection effect for a uGUI without reflection probes or shaders.
C#
112
star
14

CompositeCanvasRenderer

CompositeCanvasRenderer bakes multiple source graphics into a bake-buffer (RenderTexture) and renders it. Additional material modification, mesh modification, and baking effects are supported! Let's enjoy the effects that were difficult to implement with UI shaders, such as blur, soft outline, and soft shadow!
C#
109
star
15

DissolveEffectForTMPro

DissolveEffectForTMPro provide dissolve effect component for TextMeshPro in Unity.
C#
102
star
16

SubAssetEditor

Editor for SubAsset in unity project.
C#
101
star
17

ProjectBuilder

A tool for easy automating and customizing build process for Unity.
C#
94
star
18

UnityEventDrawerEx

This plugin extends the UnityEventDrawer to display runtime calls in the inspector.
C#
92
star
19

ShinyEffectForTMPro

ShinyEffectForTMPro provide shiny effect component for TextMeshPro in Unity.
C#
89
star
20

DissolveEffectForUGUI

A dissolve effect for uGUI, without material instancing. Please star and watch this project :)
C#
77
star
21

unity-activate

A tool to activate Unity license.
TypeScript
75
star
22

UITransition

C#
55
star
23

CompositeToggle

Composite toggle system for unity
C#
44
star
24

ButtonEx

C#
43
star
25

docker-unity

New series of CI-specialised docker images for Unity. Superseding the famous gableroux/unity3d images.
Dockerfile
34
star
26

BlurringAtlasForUGUI

A blur effect for uGUI in Unity, that is effective even for atlas images including dynamic fonts.
C#
34
star
27

SymbolCatalog

A tool for edit script symbol define for Unity.
C#
34
star
28

OpenSesame

A custom Roslyn compiler that allows access to internals/privates in other assemblies. Say "Open, Sesame!"
C#
30
star
29

MainWindowTitleModifierForUnity

A demo to change the text displayed in UnityEditor's title bar
C#
29
star
30

unity-changeset

Get/List Unity editor changeset
TypeScript
27
star
31

SimpleBuildInterface

A simple build interface for Unity CLI. Support all platforms without executeMethod option.
C#
25
star
32

unity.package-manager.metadata

Contains metadata used by the com.unity.package-manager package to fulfill client requests
Shell
25
star
33

RotateMe

Rotate the object. (This repo is a tutorial for "How to develop a package for UnityPackageManager")
Shell
23
star
34

InternalAccessibleCompilerForUnity

Compile a c# project to a internal accessible dll (for Unity)
C#
22
star
35

UISystem

C#
20
star
36

ScrollEx

C#
15
star
37

AssetSystem

C#
15
star
38

UnityBuiltinShaders

Unity's built-in shaders.
ShaderLab
13
star
39

VertexTextureFetchForUGUI

C#
11
star
40

InternalAccessibleCompiler

Compile a c# project to a internal accessible dll
C#
8
star
41

UniIx

Interactive Extensions for Unity for Unity
C#
7
star
42

Demos

6
star
43

JobcanExtensionForChrome

JavaScript
5
star
44

git-snapshot

git-snapshot is a command-line tool to take a snapshot of the directory and creates/updates another branch, like git subtree split --squash.
JavaScript
5
star
45

Coffee.Internal

Tools and snippets for package development
C#
5
star
46

unity-changeset-action

[GitHub Action] Get Unity editor change set for specific version
JavaScript
5
star
47

AtlasSystem

Atlas system for Unity
C#
4
star
48

unity-list-action

[GitHub Action] Get Unity editor versions for next jobs
JavaScript
3
star
49

UnityAdventCalendar2021

https://qiita.com/items/37978a030d6a6e262065
C#
3
star
50

ApiSystem

C#
3
star
51

mob-sakai.github.io

3
star
52

actionsflow-workflow-test

2
star
53

mob-sakai

1
star
54

UnityGitDependencyTest

A test repo for GitDependencyResolverForUnity
C#
1
star