Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How not to compile a specific file

Discussion in 'Scripting' started by unity_q2_05a_TFbgvUQ, Jul 25, 2023.

  1. unity_q2_05a_TFbgvUQ

    unity_q2_05a_TFbgvUQ

    Joined:
    Nov 28, 2021
    Posts:
    2
    I'm using NetSpell library, and i need to use file path type ".dic" that locate in project folder, and when I test the project in unity, everything works, but when I compile it and open it through the exe file in the game I get an error upload_2023-7-25_15-2-55.png

    Spelling spellWord = new Spelling();
    WordDictionary dictionary = new WordDictionary();

    private void Awake()
    {
    dictionary.DictionaryFile = "en-US.dic"; //Here is FilePath
    dictionary.Initialize();
    spellWord.ShowDialog = false;
    spellWord.Dictionary = dictionary;
    }

    I'm new to unity, so maybe you see other options how can I solve my problem
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    This library tries to load the file from the executable directory. In a build there is no user data in that directory. This is what the StreamingAssets folder is for: you can place any file to Assets/StreamingAssets folder and it will be copied verbatim to the build. You do need to provide either the relative or full path to the file to the library you are using.

    Application.dataPath + „/StreamingAssets/en-US.dic“

    should point to the right path (could not confirm though).
     
  3. unity_q2_05a_TFbgvUQ

    unity_q2_05a_TFbgvUQ

    Joined:
    Nov 28, 2021
    Posts:
    2
    Yes, it really works. I am very grateful to you stranger from the forum)