Search Unity

F# kit

Discussion in 'Assets and Asset Store' started by mischa2k, Jun 16, 2016.

  1. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Thanks, glad that you like it!
     
  2. unity_jZuf48udTzG-fg

    unity_jZuf48udTzG-fg

    Joined:
    Feb 18, 2018
    Posts:
    3
    Hi! Thank you for the kit!
    Xamarin Studio announced - 6.3 is the final release and recommend that developers now use Visual Studio on both Windows and Mac. Why kit requires xamarin?
     
  3. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    For the F# compiler mostly.
     
  4. unity_jZuf48udTzG-fg

    unity_jZuf48udTzG-fg

    Joined:
    Feb 18, 2018
    Posts:
    3
    Can we use compiler from Visual Studio?
     
  5. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Possibly, haven't tried it yet
     
  6. unity_jZuf48udTzG-fg

    unity_jZuf48udTzG-fg

    Joined:
    Feb 18, 2018
    Posts:
    3
    The problem is that Visual Studio replace and remove Xamarin Studio during installation
     
  7. rizumita

    rizumita

    Joined:
    May 28, 2018
    Posts:
    5
    I'm use Unity latest version and F# kit.
    I wrote the following code.

    Code (csharp):
    1.  
    2. namespace FSharp
    3. open UnityEngine
    4. open UnityEngine.UI
    5.  
    But this compiling error appeared.
    error FS0039: The namespace 'UI' is not defined. Maybe you want one of the following: AI

    How can I use UnityEngine.UI module?
     
  8. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Would have to add the UnityEngine.UI import to the F# project files yourself, sorry.
    F# kit will never be 100% native support, we are all hoping for Unity to do that some day. F# kit allows you to play around with F# in Unity and learn a lot though.
     
  9. Hibikine-Kage

    Hibikine-Kage

    Joined:
    Nov 9, 2013
    Posts:
    1
    Awesome work! I was wondering if this kit supports Linux.
     
  10. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Not yet, sorry
     
  11. rizumita

    rizumita

    Joined:
    May 28, 2018
    Posts:
    5
    How do I use a type that is defined in an another file?
    I defined a GameDirector type in GameDirector.fs file.
    I want to use the GameDirector type in FooController.fs file.
    Compiler said 'The type 'GameDirector' is not defined'.
     
  12. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Did you try the 'open' keyword? Like C#'s 'using'.
    Could be that we need to add files to the solution too, which would be a bit more tedious.
     
  13. rizumita

    rizumita

    Joined:
    May 28, 2018
    Posts:
    5
    > Did you try the 'open' keyword? Like C#'s 'using'.

    Yes, I tried 'open' keyword. But undefined error occurred.
     
  14. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    I am not a F# expert by any means. I just doubled checked, all the .fs files are definitely added to the .fsproj file.
    I vaguely remember someone else having a similar problem a year ago. Could it be file/compilation order dependent?
     
  15. rizumita

    rizumita

    Joined:
    May 28, 2018
    Posts:
    5
    Oh, yes. I can open by following files order.
    Must I rename files if I want to change order?
     
  16. rizumita

    rizumita

    Joined:
    May 28, 2018
    Posts:
    5
    I had to modify FSharpBuildOSX.cs.
    Code (CSharp):
    1.  
    2. using System.Linq;
    3.  
    Code (CSharp):
    1.  
    2. var scripts = Directory.GetFiles("Assets", "*.fs", SearchOption.AllDirectories).OrderBy(f => f).ToArray();
    3.  
    On another note, I modified FSharpBuildOSX.cs to use UnityEngine.UI.
    Code (CSharp):
    1.  
    2. #if UNITY_5_4_OR_NEWER
    3. public static string unityenginedllPath = EditorApplication.applicationPath + "/Contents/Managed/UnityEngine.dll";
    4. public static string unityengineuidllPath = EditorApplication.applicationPath + "/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll";
    5. #else
    6. public static string unityenginedllPath = EditorApplication.applicationPath + "/Contents/Frameworks/Managed/UnityEngine.dll";
    7. public static string unityengineuidllPath = EditorApplication.applicationPath + "/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll";
    8. #endif
    9.  
    Code (CSharp):
    1.  
    2. <Reference Include=""UnityEngine"">
    3. <HintPath>";
    4. content += unityenginedllPath;
    5. content += @"</HintPath>
    6. <Private>False</Private>
    7. </Reference>
    8. <Reference Include=""UnityEngine.UI"">
    9. <HintPath>";
    10. content += unityengineuidllPath;
    11. content += @"</HintPath>
    12. <Private>False</Private>
    13. </Reference>
    14.  
    Is this way correct?
     
  17. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Thanks for sharing. Looks fine so far. Will test it myself and push out an update!
     
  18. Sarazan

    Sarazan

    Joined:
    Apr 29, 2013
    Posts:
    12
    Thanks for making this!

    Point of interest: it looks like you can use VS for Mac as the command line build tool by changing the mdtool path to
    Code (CSharp):
    1. "/Applications/Visual Studio.app/Contents/MacOS/vstool"
    . If I'm not mistaken, this would make Xamarin Studio unnecessary?