Muahaha. I managed to get it working myself when editing. I’m using EditorGUI.LabelField() to draw an exact replica of the textarea over it, skinning the labelfield so it has colored text formatting and a clear background, and the textarea to have invisible text. That way you only see the label’s colored text, but you still get the cursor graphics from the textarea, and you have no funky richtext characters in the textarea to throw off the editing. Its working perfectly!
Thanks so much for putting me on the right path here.
1 Like
DGordon:
Muahaha. I managed to get it working myself when editing. I’m using EditorGUI.LabelField() to draw an exact replica of the textarea over it, skinning the labelfield so it has colored text formatting and a clear background, and the textarea to have invisible text. That way you only see the label’s colored text, but you still get the cursor graphics from the textarea, and you have no funky richtext characters in the textarea to throw off the editing. Its working perfectly!
Thanks so much for putting me on the right path here.
GIF it, or it didn’t happen!
thienhaflash:
bad news again, man
IndexOutOfRangeException: Array index is out of range.
System.IO.StreamReader.FindNextEOL () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/StreamReader.cs:435)
System.IO.StreamReader.ReadLine () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/StreamReader.cs:494)
System.IO.File.ReadAllLines (System.IO.StreamReader reader) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:576)
System.IO.File.ReadAllLines (System.String path) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:561)
ScriptInspector.FGFindInFiles.GetOrReadAllLinesForPath (System.String assetPath) (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGFindInFiles.cs:576)
ScriptInspector.FGFindInFiles.GetOrReadAllLines (System.String assetGuid) (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGFindInFiles.cs:564)
ScriptInspector.FGFindInFiles.FindAllInSingleFile (System.Action`4 addResultAction, System.String assetGuid, ScriptInspector.SearchOptions search) (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGFindInFiles.cs:501)
ScriptInspector.FindResultsWindow.Update () (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FindResultsWindow.cs:430)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:262)
UnityEditor.HostView.Invoke (System.String methodName) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:255)
UnityEditor.HostView.SendUpdate () (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:330)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/EditorApplicationBindings.gen.cs:249)
Thanks @thienhaflash , you’re the best! It’s seems like this is also related to those .bytes files in your project, so I’ll take care of this too…
Fattie:
Very unfortunately Script Inspector 3 is crashing every time in Mac currently .
Latest Unity, latest OSX, latest SI3.
Any time you make a change, then save, Unity crashes.
@Fattie , I’m very sorry about this! Thanks a lot for sending me over email a video of the crash, the crash log, and a test project. Since then I’m trying to reproduce the crash, but I only got it twice with a similar crash log as yours, which is not very helpful, unfortunately. I have no idea why it happens so often on your Mac, mine just doesn’t want to crash, so I wasn’t able to find a pattern that reproduces the crash. Those two cases are just not enough to find out what’s triggering it. I just upgraded my OS X to match your system and quickly tried to reproduce the crash - no luck so far, but I’ll keep trying… I hope something will come out of that very soon…
DGordon:
Just out of curiosity, how did you re-implement the whole TextArea? Almost everything I do here these days is editor stuff (game engine is basically fully built … just about making our editors better and better since it will probably be used for quite a number of years) and that sounds like knowledge which would potentially REALLY open doors for what I can do here … in no way planning on competing with your product (not that I could ;)). Was that some tremendously insane hack, or are there built in APIs in Unity which let you do that?
How much effort was it to just recreate a basic textarea, without any extra frills? I’m just testing for pre-defined keywords and coloring those with tags … if I could get something working while its being edited someday, I would love to know which direction to investigate. Super simple functionality for us, but it just makes such a huge difference.
Well, it was a huge effort, simply said. The whole Si2 cycle was about that mostly, and that lasted for a bit more than a year. I’m used to draw the text with GUI.Label but I switched later to the faster GUIStyle.Draw method. Position of each word is computed, then drawn using an already prepared GUIStyle. The blinking cursor, text selection, current line highlighting, line numbers, highlighted background on search results and symbol references, matching brackets, etc. are all drawn in a similar way.
Drawing was the easiest part though. Handling keyboard and mouse input took even more time, but it was well worth it - this gives rich UX with everything and a bit more of what users would expect from a modern code editor, and people love it!
Undo and Redo isolated per text buffer was another beast of a task. I’m so proud of how that works now!
So all that was needed only for the basic text editor. Then the Si3 cycle started - autocomplete with all the related rings and bells took a few more years! And there’s still more stuff to go in that…
I found decompiled Editor source code was the best resource to learn from. Now that’s even easier - all that’s officially supported by the Unity team. They released the source code on github: https://github.com/Unity-Technologies/UnityCsReference/tree/master/Editor/Mono
EDIT: Well, the version 1.0.0 was only a viewer and it had syntax highlighting since the initial release. That took me about 10 days only to create it from scratch, so drawing the text wasn’t a difficult task at all. Cursor navigation with selections via mouse and keyboard took several months and it lasted till the end of Si1 cycle. That was still a viewer only - editing came with Si2.
1 Like
Flipbookee:
Well, it was a huge effort, simply said. The whole Si2 cycle was about that mostly, and that lasted for a bit more than a year. I’m used to draw the text with GUI.Label but I switched later to the faster GUIStyle.Draw method. Position of each word is computed, then drawn using an already prepared GUIStyle. The blinking cursor, text selection, current line highlighting, line numbers, highlighted background on search results and symbol references, matching brackets, etc. are all drawn in a similar way.
Drawing was the easiest part though. Handling keyboard and mouse input took even more time, but it was well worth it - this gives rich UX with everything and a bit more of what users would expect from a modern code editor, and people love it!
Undo and Redo isolated per text buffer was another beast of a task. I’m so proud of how that works now!
So all that was needed only for the basic text editor. Then the Si3 cycle started - autocomplete with all the related rings and bells took a few more years! And there’s still more stuff to go in that…
I found decompiled Editor source code was the best resource to learn from. Now that’s even easier - all that’s officially supported by the Unity team. They released the source code on github: https://github.com/Unity-Technologies/UnityCsReference/tree/master/Editor/Mono
EDIT: Well, the version 1.0.0 was only a viewer and it had syntax highlighting since the initial release. That took me about 10 days only to create it from scratch, so drawing the text wasn’t a difficult task at all. Cursor navigation with selections via mouse and keyboard took several months and it lasted till the end of Si1 cycle. That was still a viewer only - editing came with Si2.
Thanks for all the information. I really appreciate it :).
1 Like
Fattie:
Very unfortunately Script Inspector 3 is crashing every time in Mac currently .
Latest Unity, latest OSX, latest SI3.
Any time you make a change, then save, Unity crashes.
@Fattie I have some good news to share with you - Unity fixed the crash in version 2018.1.7 released just 2 days ago! Versions 2018.1.5 and 2018.1.6 contain the bug and it won’t be fixed because it seems like Unity stopped releasing patches for Unity 2018, but you can avoid using these version…
Thanks to all the details about the crash you shared with me over email, I also managed to find a workaround for using Si3 in Unity 2018.1.5 and 2018.1.6! I’ll release the workaround today to avoid receiving negative reviews. Just got one by @superFAST2022 but that’s the life - each time Unity introduces a severe bug like this, Si3 receives negative reviews even though that’s not my fault at all. That’s why it’s very important to post a positive review if Si3 is making you enjoy working in Unity as never before! Thanks so much to all of you who already did that, and if you haven’t done that yet, it’s the best time for that now! Here’s the link where you can do that: https://www.assetstore.unity3d.com/en/?stay#!/content/3535 and thanks in advance
Please watch this thread. I’ll announce here when the hotfix is available on Asset Store and it will include all the other minor fixes that were done during the last month.
3 Likes
Appreciate the insights and support!
I use use this tool every day, can’t imagine anymore how people work with external
editors, so much faster using internal.
3 Likes
Fattie
July 15, 2018, 7:43pm
2229
Has anyone had this suggestion ?!
the actual “close tab” button could be:
I s it possible ?!
That would be huge!
1 Like
You can also use the middle mouse click to close Unity tabs, same as in your browser.
1 Like
Any plans for folding regions support?
3 Likes
Yes, right after releasing the Rename refactoring. I was working on that for a while and I got it half working at that time, now I’d only have to finish that.
1 Like
Fattie
July 16, 2018, 11:52pm
2233
In OSX - Xcode,
To fold whatever you’re currently inside
the key stroke is
Option-Command-LeftArrow
it gets really built-in to your fingers. I hope this is the keystroke in SI3
Folding would be huge, huge.
1 Like
bad news, man, bad news
IndexOutOfRangeException: Array index is out of range.
FGTextBuffer.FormatLine (Int32 currentLine) (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGTextBuffer.cs:2647)
FGTextBuffer.ReformatLines (Int32 fromLine, Int32 toLineInclusive) (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGTextBuffer.cs:2633)
FGTextBuffer.ProgressiveLoadOnUpdate () (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGTextBuffer.cs:712)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/EditorApplicationBindings.gen.cs:249)
1 Like
thienhaflash:
bad news, man, bad news
IndexOutOfRangeException: Array index is out of range.
FGTextBuffer.FormatLine (Int32 currentLine) (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGTextBuffer.cs:2647)
FGTextBuffer.ReformatLines (Int32 fromLine, Int32 toLineInclusive) (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGTextBuffer.cs:2633)
FGTextBuffer.ProgressiveLoadOnUpdate () (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGTextBuffer.cs:712)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/EditorApplicationBindings.gen.cs:249)
That’s a strange error, but it should be easy to fix… Thanks @thienhaflash !
Fattie:
In OSX - Xcode,
To fold whatever you’re currently inside
the key stroke is
Option-Command-LeftArrow
it gets really built-in to your fingers. I hope this is the keystroke in SI3
Folding would be huge, huge.
Hmm, Alt-Cmd-Left arrow in Si3 moves the cursor back to its previous position… complicated …
sngdan
July 25, 2018, 7:43am
2237
Hi, I get this error, when I check for references (right click → FindAllReferences)
2018.2.0f2 (with ECS) on Mac
Net 4.x
IL2CPP
console
ArgumentException: Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results. IComparer: 'System.Comparison`1[System.String]'.
System.Collections.Generic.IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer (System.Object comparer) (at <f826c2584fc94ec19a48a6576640bdc5>:0)
System.Collections.Generic.ArraySortHelper`1[T].Sort (T[] keys, System.Int32 index, System.Int32 length, System.Comparison`1[T] comparer) (at <f826c2584fc94ec19a48a6576640bdc5>:0)
System.Collections.Generic.List`1[T].Sort (System.Comparison`1[T] comparison) (at <f826c2584fc94ec19a48a6576640bdc5>:0)
ScriptInspector.FGFindInFiles.FindReferenceCandidates (ScriptInspector.SymbolDefinition symbol, System.String localAssetPath) (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGFindInFiles.cs:469)
ScriptInspector.FGFindInFiles.FindAllReferences (ScriptInspector.SymbolDefinition symbol, System.String localAssetPath) (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGFindInFiles.cs:101)
ScriptInspector.FGTextEditor+<>c__DisplayClass204_3.<DoGUI>b__12 () (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGTextEditor.cs:2799)
UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, System.Int32 selected) (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/GenericMenu.cs:121)
1 Like
sngdan:
Hi, I get this error, when I check for references (right click → FindAllReferences)
2018.2.0f2 (with ECS) on Mac
Net 4.x
IL2CPP
console
ArgumentException: Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results. IComparer: 'System.Comparison`1[System.String]'.
System.Collections.Generic.IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer (System.Object comparer) (at <f826c2584fc94ec19a48a6576640bdc5>:0)
System.Collections.Generic.ArraySortHelper`1[T].Sort (T[] keys, System.Int32 index, System.Int32 length, System.Comparison`1[T] comparer) (at <f826c2584fc94ec19a48a6576640bdc5>:0)
System.Collections.Generic.List`1[T].Sort (System.Comparison`1[T] comparison) (at <f826c2584fc94ec19a48a6576640bdc5>:0)
ScriptInspector.FGFindInFiles.FindReferenceCandidates (ScriptInspector.SymbolDefinition symbol, System.String localAssetPath) (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGFindInFiles.cs:469)
ScriptInspector.FGFindInFiles.FindAllReferences (ScriptInspector.SymbolDefinition symbol, System.String localAssetPath) (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGFindInFiles.cs:101)
ScriptInspector.FGTextEditor+<>c__DisplayClass204_3.<DoGUI>b__12 () (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGTextEditor.cs:2799)
UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, System.Int32 selected) (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/GenericMenu.cs:121)
Wow, that’s an interesting one… Is there a way you could share that project with me?
sngdan
July 25, 2018, 6:24pm
2239
@Flipbookee
I just figured out that this error happens in an empty project with only SI3 installed - it seems to be related to Net4.x
Net4.x → Error
Net3.5 → No Error
1 Like
I found the issue - it was my fault and .Net 3.5 wasn’t complaining about that, but .Net 4.6 does. I’ll fix it quickly!