OpenSesameCompilerForUnity 使用教程

OpenSesameCompilerForUnity 使用教程

OpenSesameCompilerForUnityA 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!"项目地址:https://gitcode.com/gh_mirrors/op/OpenSesameCompilerForUnity

1. 项目的目录结构及介绍

OpenSesameCompilerForUnity 项目的目录结构如下:

OpenSesameCompilerForUnity/
├── Assets/
│   ├── Editor/
│   │   ├── OpenSesameCompiler/
│   │   │   ├── Editor/
│   │   │   │   ├── OpenSesameCompilerSettings.cs
│   │   │   │   └── ...
│   │   │   ├── OpenSesameCompiler.asmdef
│   │   │   └── ...
│   │   └── ...
│   ├── Tests/
│   │   ├── CoffeeOpenSesameTest/
│   │   │   ├── CoffeeOpenSesameTest.asmdef
│   │   │   └── ...
│   │   └── ...
│   └── ...
├── CHANGELOG.md
├── LICENSE
├── README.md
└── ...

目录介绍

  • Assets/: Unity 项目的主要目录,包含所有资源和代码。
    • Editor/: 包含编辑器扩展代码,用于在 Unity 编辑器中配置和使用 OpenSesameCompiler。
      • OpenSesameCompiler/: OpenSesameCompiler 的核心代码目录。
        • Editor/: 包含编辑器扩展的具体实现。
          • OpenSesameCompilerSettings.cs: 配置 OpenSesameCompiler 的主要文件。
        • OpenSesameCompiler.asmdef: 定义 OpenSesameCompiler 的程序集。
    • Tests/: 包含测试代码。
      • CoffeeOpenSesameTest/: 示例测试项目。
        • CoffeeOpenSesameTest.asmdef: 定义测试程序集。
  • CHANGELOG.md: 项目更新日志。
  • LICENSE: 项目许可证(MIT)。
  • README.md: 项目介绍和使用说明。

2. 项目的启动文件介绍

项目的启动文件主要是 OpenSesameCompilerSettings.cs,它位于 Assets/Editor/OpenSesameCompiler/Editor/ 目录下。这个文件负责配置 OpenSesameCompiler 的设置,包括是否启用 OpenSesameCompiler、添加或移除编译符号等。

启动文件介绍

// OpenSesameCompilerSettings.cs
using UnityEditor;
using UnityEngine;

public class OpenSesameCompilerSettings : EditorWindow
{
    // 配置项
    private bool useOpenSesameCompiler = true;
    private string modifySymbols = "";
    private bool portableMode = false;

    // 显示设置窗口
    [MenuItem("Window/OpenSesame Compiler Settings")]
    public static void ShowWindow()
    {
        GetWindow<OpenSesameCompilerSettings>("OpenSesame Compiler Settings");
    }

    private void OnGUI()
    {
        // 配置项的具体设置
        useOpenSesameCompiler = EditorGUILayout.Toggle("Use OpenSesame Compiler", useOpenSesameCompiler);
        modifySymbols = EditorGUILayout.TextField("Modify Symbols", modifySymbols);
        portableMode = EditorGUILayout.Toggle("Portable Mode", portableMode);
    }
}

3. 项目的配置文件介绍

项目的配置文件主要是 OpenSesameCompiler.asmdef,它位于 Assets/Editor/OpenSesameCompiler/ 目录下。这个文件定义了 OpenSesameCompiler 的程序集,包括程序集名称、依赖项等。

配置文件介绍

// OpenSesameCompiler.asmdef
{
    "name": "OpenSesameCompiler",
    "references": [],
    "includePlatforms": [
        "Editor"
    ],
    "excludePlatforms": [],
    "allowUnsafeCode": false,
    "overrideReferences": false,
    "precompiledReferences": [],
    "autoReferenced": true,
    "defineConstraints": [],
    "versionDefines": [],
    "noEngineReferences": false
}

配置项介绍

  • name: 程序集名称。
  • references: 依赖的程序集。
  • includePlatforms: 包含的平台(这里是 Editor)。
  • excludePlatforms: 排除的平台。
  • allowUnsafeCode: 是否允许不安全的代码。

OpenSesameCompilerForUnityA 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!"项目地址:https://gitcode.com/gh_mirrors/op/OpenSesameCompilerForUnity

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

1. 内容概要 本项目是一个支持科学函数的命令行计算器,兼容 C++98 标准。它实现了中缀表达式词法分析、后缀表达式转换与求值,支持常见数学运算(如幂、三角函数、对数等)与括号优先级解析。程序还提供了角度版三角函数、角度与弧度互转功能,并支持函数调试输出与函数演示模式。 2. 适用人群 * C++ 初中级学习者,特别是希望深入理解表达式求值机制者 * 需要一个可扩展的计算引擎的项目开发者 * 想通过项目实践词法分析、调度场算法、数学函数封装的开发者 * 高校学生课程设计、编译原理实践者 3. 使用场景及目标 * 实现中缀表达式的完整求解器,支持函数嵌套、优先级与结合性处理 * 提供角度与弧度版本的三角函数,以适应不同输入偏好 * 演示中缀转后缀过程,辅助编程教育与算法教学 * 提供科学函数辅助计算,如 `log`, `sqrt`, `abs`, `exp`, `ceil`, `floor` 等 4. 其他说明 * 支持函数:sin, cos, tan(弧度);sind, cosd, tand(角度) * 支持函数嵌套,如 `sin(deg2rad(30))` * 支持操作符:+, -, \*, /, ^, \*\*(幂运算)与括号优先级 * 所有函数均通过 map 注册,方便扩展与自定义 * 输入 `help` 查看支持函数,`demo` 观看转后缀过程,`quit` 退出程序 * 提示用户避免使用 `°` 符号,推荐使用角度函数代替 * 可通过 `g++ calculator.cpp -o calculator -lm` 编译(需链接数学库)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杭云瑗Ward

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值