Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
3
Help us understand the problem. What is going on with this article?
@K0uhe1D

M1 macでUnityエディタにVS code使ってC#の構文解析する時のメモ

超大事: monoを入れるときにx86版のbrew を使う

前提

環境

必須なVScode拡張機能

brewでアーキテクチャの切り替えをできるようにする

  • この設定ファイルを適用することで

    • switch-archでアーキテクチャの切り替えが可能
    • $ brew はx86アーキテクチャを使用
    • $ =brew はarm アーキテクチャを使用
    • $ uname -m アーキテクチャを確認
  • ~/.zshrc に以下を追記する

typeset -U path PATH
path=(
    /opt/homebrew/bin(N-/)
    /usr/local/bin(N-/)
    $path
)

if (( $+commands[sw_vers] )) && (( $+commands[arch] )); then
    [[ -x /usr/local/bin/brew ]] && alias brew="arch -arch x86_64 /usr/local/bin/brew"
    alias x64='exec arch -x86_64 /bin/zsh'
    alias a64='exec arch -arm64e /bin/zsh'
    switch-arch() {
        if  [[ "$(uname -m)" == arm64 ]]; then
            arch=x86_64
        elif [[ "$(uname -m)" == x86_64 ]]; then
            arch=arm64e
        fi
        exec arch -arch $arch /bin/zsh
    }
fi

setopt magic_equal_subst

monoをx86のbrewでインストールする

$ brew install mono
$ mono -v
Mono JIT compiler version 6.12.0.125 (2020-02/8c552e98bd6 Mon Mar  8 13:06:52 EST 2021)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           
    SIGSEGV:       altstack
    Notification:  kqueue
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug 
    Interpreter:   yes
    LLVM:          yes(610)
    Suspend:       hybrid
    GC:            sgen (concurrent by default)

Unityでの設定

  • 設定よりエディタをVisual Studio Code に変更
  • "Generate .csproj file for"のチェックボックスに全てチェックをいれる
  • "Regenerate project file" を押してcsprojファイルを生成

VScode側の設定

  • Unity側でc#のスクリプトファイルを開く
  • デフォルトだとエラーがでる
  • OUTPUTのC#の部分で
[fail]: OmniSharp.MSBuild.ProjectLoader
        The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

というエラーがでるのでVScodeの設定
"Manage"->"Settings"-> "Omnisharp: Use Global Mono"
の項目をalwaysに変更する(デフォルトはauto)

注意

現在(2021/04/01)構文解析が動かなかったりc#のファイル読み込みでエラーがでたりちょっと動作が不安定な気がした

# 参考
- https://zenn.dev/nmrtkhs/articles/0b75959281c9a7
- https://zenn.dev/ress/articles/069baf1c305523dfca3d

THX: @Inaba

3
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
3
Help us understand the problem. What is going on with this article?