Search Unity

[Released] InGame Code Editor

Discussion in 'Assets and Asset Store' started by scottyboy805, Apr 17, 2019.

  1. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    InGame Code Editor is an advanced input field for Unity that makes use of TextMesh Pro to display syntax highlighted code. Much of the inspiration for the syntax highlighting is taken from notepad++ and as a result it is extremely customizable allowing you to add syntax highlighting support for new languages.

    Requirements
    • Requires TextMesh Pro (Installable via package manager)
    Features
    • Very easy to use. Just drop the prefab into your scene and customize
    • Full text editing features that you would expect
    • Includes optional line numbers column
    • Fully customizable editor themes
    • Includes 3 pre-set themes: Light, Dark and Terminal
    • Fully customizable syntax highlighting
    • Highly optimized lexer for quick syntax highlighting of large text
    • Supports syntax highlighting of keywords, symbols, numbers, comments and quote strings
    • Keyword groups mean that you can highlight keywords in different colors
    • Built in syntax highlighting support for C# (multiple), Lua, MiniScript and JSON
    • You can easily add support for additional syntax highlighted languages
    • Supports basic auto indentation using opening and closing tags
    • Comprehensive .chm documentation of the API for quick and easy reference
    • Fully commented C# source code included

    Theme Screenshot.png
     

    Attached Files:

    Last edited: May 7, 2019
    JBR-games, OldYawn and joshcamas like this.
  2. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    We are pleased to announce that InGame Code Editor has now been approved and is live on the asset store. Check if out here!
     
  3. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    InGame Code Editor version 1.0.1 has been submitted to the asset store for review. This version fixes a minor issue where line comments and block comments starting with similar characters would not be handled correctly.
     
  4. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    InGame Code Editor version 1.0.2 has been submitted to the asset store for review. This version adds syntax highlighting for javascript core.
     
  5. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    InGame Code Editor version 1.0.3 has been submitted to the asset store for review. This version contains:
    • Fixed an auto indenting bug where deep levels of indenting were not handled correctly
    • Fixed an auto indenting bug where the closing character could exist on the same line as the caret
    • Auto indent closing characters will now be placed on a new line if required and the caret will be moved to the previous line after the auto indent tab string.
     
  6. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    InGame Code Editor version 1.0.4 has been submitted to the asset store. This version fixes a syntax highlighting bug and also adds basic auto tab support for all language themes. Adding a new line will now cause the caret to be auto tabbed based upon the previous line.
     
  7. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    InGame Code Editor version 1.0.6 has been submitted to the asset store.
    • Added a compatibility option for TMP to apply line height fix (Unity 2018.2 and newer). This may be required depending upon the TMP version you are using to correctly sync the line highlighter in the code window.
    • Fixed a bug where the line highlighter could become out of sync when some text is deleted.
    • Fixed a bug where the line numbers would not be synced correctly when deleting all text.
     
    zyzyx likes this.
  8. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    236
    Is there a sample integration provided with support for your Roslyn asset? Esp. in 2019.3 beta now that it works. Or even better for your uMod 2?
     
  9. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    Hi, We have not added anything like this yet. What sort of sample would you like to see? Just a demo scene using IGCE with Roslyn C# or something more? It may take a bit of work to distribute something like this as thee will be 2 asset requirements but we should be able to work something out.
     
  10. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    236
    Correct just a simple demo. I think it helps promote sales, esp. if the integrations are tested or at least fixed when reported. I try to buy assets that work together - even better if there is a basic integration already made showing best practices between the assets I want to use.
     
  11. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    Yes we can certainly add something like that to Roslyn C#. It is not something that we would add to uMod at the moment because currently uMod does not contain any means to compile code at runtime so a code editor would not be very useful.
     
  12. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    236
    For uMod - let me paint a use case.

    Unity editor is a very powerful tool for Linux users. It can be hard for new users to figure out how to setup mono / vscode to act as an editor to a unity project with Linux Unity Editor. It is already a tough sell to convince potentional modders to dive into the Unity version madness. Near impossible to get them to buy into sorting through all the issues with Unity Editor on Linux while also getting a decent code environment setup.

    Enter ingame code. Now if there was a way to offer a lite version, something we could include in our mod kit we provide (great implementation btw) or something that let the modders code while in play mode within Unity. The user experience is far better to get started modding. (which we want to be easy to start and see the potential)

    They can get started, and when ready to mess with the editor and code env. on Linux, they can cross that bridge when they need to.

    I'm not saying solve all that. Stuff like saving and loading files etc. is not within the realm of the idea. I'm mainly just trying to see if there might be a way to offer it for the modders so when they hit play, they can start coding right in Unity to get their feet wet.
     
  13. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    Thanks for the use case. I can understand how it IGCE could be useful in this situation however currently there is not real any possible interconnectability with uMod and IGCE. IE you cant just write code at runtime and pass that code to uMod so I don't think a demo scene would be very useful in this situation. You would essentially just end up with the default IGCE demo scene and nothing more. If you wanted to use IGCE along with uMod you could just import the asset and use the documentation to set it up in addition. If further down the line we added the feature you describe allowing modders to write code in playmode while developing mods then we could certainly add an extra demo at that point.
     
    CommunityUS likes this.
  14. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    In Game Code Editor version 1.0.7 has been submitted to the asset store for review and should be available for download within a few days. This version includes:
    • Added an integration demo package showing how IGCE can integrate into our other asset Rolsyn C#
    • Fixed a null reference exception which occured when the 'Text' property was assgined but the code editor component or game object was disabled.
    • Fixed a bug where the line highlight would stay fixed in position relative to the screen when scrolling via the mouse wheel or scroll bar.
    • Fixed a bug where the 'Text' property of the code editor would sometimes return a string with an additional '"' character.
     
  15. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    In Game Code Editor version 1.0.8 has been submitted to the asset store. This version allows you to move the line highlight bar to a specific line via code. You can now also lock the line highligh bar in position to prevent the user from moving it when editing text which could be useful for debug step though features or similar.
     
  16. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    In Game Code Editor version 1.0.9 has been submitted to the asset store. This version fixes an issue where setting the code editor text via script would not update the line numbers correctly.
     
  17. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    235
    When I add the integration package there are errors for

    Assets\InGameCodeEditor_CompatibilityDemo\RoslynCSharp_CompatibilityDemo\Scripts\IGCEMazeCrawlerExample.cs(109,66): error CS1503: Argument 1: cannot convert from 'System.Reflection.Assembly' to 'RoslynCSharp.Compiler.IMetadataReferenceProvider'

    Repeated for each of the 4 lines there.

    (I'm using 2019.4.01f1 if that might make the difference)
     
  18. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    Hi,
    Thanks for reporting these errors. It looks like the compatibility demo was not updated to support the latest Roslyn C# version. We have now fixed this and will be submitting an update for IGCE shortly. I have sent you a PM with the update package so you don't have to wait for the update to be released.
     
    MrIconic likes this.
  19. VpzomTrrfrt

    VpzomTrrfrt

    Joined:
    Dec 2, 2016
    Posts:
    6
    I'm running into an issue with caret placement (with Unity 2018.4.24f1 and TMP 1.4.1): If I set the Text property from another script, then the user clicks into the text field past the end of the line, the caret is placed one character before the end, while I would expect it to be at the very end of the line. Clicking again seems to place it correctly.
     
  20. VpzomTrrfrt

    VpzomTrrfrt

    Joined:
    Dec 2, 2016
    Posts:
    6
    Additionally, setting Text to an empty strings causes it to throw IndexOutOfRangeException every frame until I focus the editor
     
  21. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    Hi,
    Thanks for reporting these issues.
    We were able to reproduce both issues after a bit of testing. The caret position issue when focusing the code editor after setting the text via script has now been fixed and now works as expected. We have also fixed the IndexOutOfRange exception when clearing the code editor text by setting the text property to an empty string. We will be releasing an update shortly with these fixes.
    Let me know if there is anything else.
     
    VpzomTrrfrt likes this.
  22. VpzomTrrfrt

    VpzomTrrfrt

    Joined:
    Dec 2, 2016
    Posts:
    6
    Now I have another issue: If I instantiate a prefab containing the CodeEditor, then set its text, the scrollbar doesn't appear, even if the text is long enough to warrant one
     
  23. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    Hi,
    Sorry for not replying sooner. I did not recieve a notification that you had posted a message.

    We have tested this and were able to reproduce the issue in Unity 2018.3. However, after a lot of debugging and testing, it looks like the issue is with TMP not updating the scroll bar for instantiated instances. We have checked many times and we are using the API correctly, but the scroll bar is simply not updated after the code editor is instantiated. The only way we have been able to fix this is to manually call an internal TMP method using reflection which causes the scroll bar to be updated and then everything works as exepcted. It is a hack and is not ideal but it is the only option we have at this point. We will be submitting an update shortly with the changes.

    Let me know if there is anything else.
     
  24. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    InGame Code Editor 1.1.2 has been submitted. This version fixes an issue raised above where instantiating a code editor and then assigning a long text string will not update the scroll bar as expected.
     
  25. VpzomTrrfrt

    VpzomTrrfrt

    Joined:
    Dec 2, 2016
    Posts:
    6
    It looks like line wrapping is breaking line numbering. If line 1 is long enough to overflow, part of it gets labeled as line 2, even though there is no newline
     
  26. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    Hi,
    Thanks for reporting this issue.
    We were able to replicate the problem and have now fixed the issue. Entering a long line of text will now cause a new line to be created by word wrapping but the line numbering will be blank until the next actual new line. You can see the results here:

    WordWrappedLineNumbering.png


    We will be submitting an update shortly with these changes and it should hopefully be available for download within a day or two.

    Let me know if there is anything else.
     
  27. Sandro-7

    Sandro-7

    Joined:
    May 25, 2013
    Posts:
    5
    Hello, it's the first time I use this component. So I followed the instructions included but I have a problem. When I execute my game, I see the editor GUI, but obviously my game is running back to the editor. When I click on the editor I cannot type anything, the editor does not accept any pressed key. It seems "locked".
    What can I do?
    Thank you for your help!
     
  28. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    Hi,
    Thanks for using our asset.
    Do you mean that you cannot type into the code editor from the scene view? If so, that is correct and the component only works at runtime via the Play window.
    If you mean that you cannot type in play mode then I would check that TextMesh Pro is setup correctly. We do not handle any input our selfs, but instead built the code editor on top of a Text Mesh Pro input field.
    1. Check that TMP is setup by going to 'Window -> TextMeshPro -> Import TMP Essential Resources'. If you do not see the TMP menu under 'Window', then you likely do not have TMP installed. You can install it via the package manager.
    2. Ensure that the code editor is focused by clicking the mouse inside before typing. The code editor must be focused in order to receive input.
    3. Try creating a TMP input field to see if that works as expected (This will rule out TMP being the cause of the problem). Create a new game object in the scene and go to 'Component -> UI -> TextMeshPro - Input Field'. Test this field in game and if it works correctly, the issue will be with our asset and we will have to look into it further.
    I hope this help you. Let me know if you are still having issues.
     
  29. jamsmith

    jamsmith

    Joined:
    Sep 15, 2021
    Posts:
    1
  30. dujimache

    dujimache

    Joined:
    Dec 17, 2011
    Posts:
    87
    hello, does ingame code editor support right-click context menu?such as copy 、pase 、undo、redo??and IntelliSense???
     
  31. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,003
    Hi, In Game Code Editor is just a basic input field with syntax highlighting and some other features, so it does not have copy, paste etc by default. It is best to think of it like a replacement UI input field, a bit like TMP Input Field, with extra features like syntax highlighting.
    You can certainly add a UI context menu yourself though if you need it by building it out of other UI elements. The asset also does not have support for intellisense since that is a complex thing to implement. Only syntax highlighting for a few common languages and a few other nice features like themes.
    I hope that helps you. Let me know if there is anything else.
     
unityunity