File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 5
5
using System . IO ;
6
6
using System . Linq ;
7
7
using System . Reflection ;
8
+ using System . Text ;
8
9
using UdonSharp ;
9
10
using UdonSharp . Serialization ;
10
11
using UnityEditor ;
@@ -42,6 +43,25 @@ public static UdonAssemblyProgramAsset UdonSharpProgramToAssemblyProgram(UdonSha
42
43
43
44
string programAssembly = UdonSharpEditorCache . Instance . GetUASMStr ( udonSharpProgramAsset ) ;
44
45
46
+ // Strip comments/inline code
47
+ StringBuilder asmBuilder = new StringBuilder ( ) ;
48
+
49
+ using ( StringReader reader = new StringReader ( programAssembly ) )
50
+ {
51
+ string line = reader . ReadLine ( ) ;
52
+
53
+ while ( line != null )
54
+ {
55
+ if ( ! string . IsNullOrWhiteSpace ( line ) &&
56
+ ! line . TrimStart ( ) . StartsWith ( "#" , System . StringComparison . Ordinal ) )
57
+ asmBuilder . AppendFormat ( "{0}\n " , line ) ;
58
+
59
+ line = reader . ReadLine ( ) ;
60
+ }
61
+ }
62
+
63
+ programAssembly = asmBuilder . ToString ( ) ;
64
+
45
65
FieldInfo assemblyField = typeof ( UdonAssemblyProgramAsset ) . GetField ( "udonAssembly" , BindingFlags . NonPublic | BindingFlags . Instance ) ;
46
66
assemblyField . SetValue ( newProgramAsset , programAssembly ) ;
47
67
You can’t perform that action at this time.
0 commit comments