Search Unity

Lua files can’t have a .lua extension (Feature Request: allow this)

Discussion in 'Editor & General Support' started by alakoring, Nov 12, 2020.

  1. alakoring

    alakoring

    Joined:
    Mar 11, 2018
    Posts:
    27
    I am using MoonSharp to have Lua scripts in my game. (Normally these would end in .lua …)
    In order to load a script (as TextAsset), it must be renamed to end in .txt.
    This means that external editors can’t recognize the file as Lua, and you lose syntax highlighting.

    As an additional enhancement, it would be nice to specify additional extensions to be treated as TextAsset. I have specialized data files that are not Lua or JSON, and it would be convenient to give them their own file extension, not .txt.
     
    PraetorBlue likes this.
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    Yeah this has long been a thorn in my side. Ideally we would get a menu where we could map any file extension to any asset type. Then we could easily set things up as we want. Some common ones:
    • .lua -> Text
    • .json -> Text
    • .xml -> Text
    • .mygamedata -> Text
    etc..
     
    Last edited: Nov 12, 2020
    alakoring likes this.
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Can you load the lua files at runtime from StreamingAssets instead of using them as a TextAsset? If so you should be able to keep the .lua extension.