Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Radivarig · Feb 09, 2015 at 04:19 AM · c#monodeveloplinuxautocomplete

open C# scripts on Linux in native monodevelop

Linux? Did I read it right?

Hell yeah! I have been using Unity on arch linux for some time and there's a great script available that automates the installation and handles workarounds for errors.

But, I couldn't get C# autocompletion in any text editor the way I was used to in monodevelop so I wrote the script below that formats parameters (*-csharp.sln, filename.cs, fileline) in a way monodevelop can handle.

Test and let me know how it goes, good luck!

~Radivarig

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image steakpinball · Feb 09, 2015 at 02:32 PM 0
Share

This is more appropriate for the forums.

avatar image Radivarig · Feb 09, 2015 at 02:35 PM 1
Share

It is an important code snippet that answers a question of how to, therefore it is an answer and belongs here.

1 Reply

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by Radivarig · Feb 09, 2015 at 04:23 AM

Once you install your Unity on Linux:

  • save this script as unity3d_native_monodevelop.sh

  • this is a bash script, give it execution permission with chmod +x unity3d_native_monodevelop.sh

  • open Unity and go to Edit>Preferences>ExternalEditor and select this script

  • put "$(File)" $(Line) as parameters

That's it!

 #!/bin/bash
 if [ -z "$1" ]; then exit 1; fi
 
 if [ "$1" == "--nologo" ]
 then
     WIN_FILE_PATH="${3%;*}"
     FILE_LINE="${3##*;}"
 else
     WIN_FILE_PATH="$1"
     FILE_LINE="$2"
 fi
 if [ "$FILE_LINE" == "-1" ]; then FILE_LINE="0"; fi
 
 FILE_PATH=$(winepath -u "$WIN_FILE_PATH")
 if [[ "$WIN_FILE_PATH" == *.sln ]]; then FILE_PATH=$(dirname "$FILE_PATH"); fi
 SLN_DIR="${FILE_PATH%%/Assets/*}"
 SLN_PATH=$(find "$SLN_DIR" -maxdepth 1 -name "*-csharp.sln")
 SLN_NAME="${SLN_PATH#${SLN_DIR}/}"
 SLN_NAME="${SLN_NAME#$?}"
 LOCAL_FILE_PATH="${FILE_PATH#$SLN_DIR}"
 LOCAL_FILE_DIR=$(dirname "$LOCAL_FILE_PATH")
 FILE_NAME="${LOCAL_FILE_PATH#${LOCAL_FILE_DIR}/}"
 
 export WINEPREFIX="${SLN_DIR%%/dosdevices/z*}/"
 if [[ $FILE_PATH == *".js" ]]
 then
     SLN_NAME="${SLN_NAME/-csharp/}"
     PREV_SLN_NAME=$(head -n 1 "${SLN_DIR}/sln_name_of_last_monodevelop_call_js")
     
     WIN_SLN_DIR="$(winepath -w "$SLN_DIR")"

     MD_PATH="${WINEPREFIX}drive_c/Program Files/Unity/MonoDevelop/bin/MonoDevelop.exe"
     
     if [ "$(pidof MonoDevelop.exe)" ] && [ $PREV_SLN_NAME == $SLN_NAME ]
     then wine "$MD_PATH" "$WIN_FILE_PATH;$FILE_LINE"
     else wine "$MD_PATH" "${WIN_SLN_DIR}\\$SLN_NAME $WIN_FILE_PATH;$FILE_LINE"
     fi
     echo "$SLN_NAME" > "${SLN_DIR}/sln_name_of_last_monodevelop_call_js"
     exit 0
 fi
 
 COUNT="${LOCAL_FILE_PATH//[^\/]}"
 COUNT="${#COUNT}"
 COUNT="$((COUNT - 2))"
 
 BACKWARD_SLN_DIR=""
 for i in $(seq 0 $COUNT); do BACKWARD_SLN_DIR="${BACKWARD_SLN_DIR}../"; done
 
 ln -s "/" "${SLN_DIR}/Z:"
 ln -s "${WINEPREFIX}dosdevices/c:" "${SLN_DIR}/C:"
 
 cd "${SLN_DIR}$LOCAL_FILE_DIR"
 PREV_SLN_NAME=$(head -n 1 "${SLN_DIR}/sln_name_of_last_monodevelop_call")
 echo "$SLN_NAME" > "${SLN_DIR}/sln_name_of_last_monodevelop_call"
 
 MD_PATH="$(which monodevelop)"
 if [[ "$WIN_FILE_PATH" == *".sln" ]]
 then
     if [ -z "$(pidof monodevelop)" ]
     then "$MD_PATH" "$SLN_NAME"
     fi
 else
     if [ "$(pidof monodevelop)" ] && [ $PREV_SLN_NAME == $SLN_NAME ]
     then "$MD_PATH" "$FILE_NAME;$FILE_LINE"
     else "$MD_PATH" "${BACKWARD_SLN_DIR}$SLN_NAME $FILE_NAME;$FILE_LINE"
     fi
 fi
 exit 0

~Radivarig

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image demented_hedgehog · Feb 10, 2015 at 01:11 AM 0
Share

That's interesting because unity's first arg for me is --nologo (which then breaks your script at line 4 for me as winepath returns nothing). In fact the args I'm seeing are --nologo sln_path file_path;line_number. Also my version of this keeps opening new monodevelop windows - sigh.

avatar image Radivarig · Feb 15, 2015 at 08:43 PM 0
Share

I've got another report that Unity doesn't send specified arguments so I made a fix for that above. Thanks for testing!

avatar image demented_hedgehog · Sep 15, 2015 at 03:57 AM 0
Share

Just for the record.. underlying problem here is due to the difference between ArchLinux and Ubuntu and its derivatives. Ubuntu uses dash for /bin/sh and has monodevelop in /usr/bin/monodevelop. So change the first line to /bin/bash and replace /bin/monodevelop with /usr/bin/monodevelop on ubuntu.

avatar image GabLeRoux · Oct 02, 2015 at 12:39 AM 2
Share

I think installing monodevelop can help too ;) sudo apt-get install monodevelop -y. Won't run unity's built in monodevelop, but at least it worked for me on ubuntu. Thanks for sharing this script.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Remove automatic space before () in MonoDevelop autocomplete 1 Answer

When i open C#-Scripts with MonoDevelop, MonoDevelop shows starting screen. 2 Answers

Autocomplete not working for inherted methods 1 Answer

I use Ubuntu, but Monodevelop Autocomplete is not working. is there some additional Add in ? 1 Answer

New Scripts have no autocomplete.. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges