@@ -426,9 +426,7 @@ public void GenerateShader()
426
426
427
427
PostGeneration ? . Invoke ( ShaderFile , this ) ;
428
428
429
- MatchCollection m = Regex . Matches ( ShaderFile . ToString ( ) , @"#K#.*$" , RegexOptions . Multiline ) ;
430
- for ( int i = m . Count - 1 ; i >= 0 ; i -- )
431
- ShaderFile . Replace ( m [ i ] . Value , "" ) ;
429
+ RemoveKeywords ( ) ;
432
430
433
431
ShaderFile . Replace ( "\r \n " , "\n " ) ;
434
432
@@ -539,7 +537,7 @@ private void WriteShaderSkeleton()
539
537
}
540
538
}
541
539
}
542
- MatchCollection mkr = Regex . Matches ( ShaderFile . ToString ( ) , @"#KI#\S* " , RegexOptions . Multiline ) ;
540
+ MatchCollection mkr = Regex . Matches ( ShaderFile . ToString ( ) , @"#KI#.*$ " , RegexOptions . Multiline ) ;
543
541
for ( int i = mkr . Count - 1 ; i >= 0 ; i -- )
544
542
ShaderFile . Replace ( mkr [ i ] . Value , "" ) ;
545
543
//}
@@ -654,7 +652,38 @@ private void WriteFunctionCallSequence(StringBuilder callSequence, string append
654
652
}
655
653
}
656
654
657
- //check a line of the property block
655
+ // Remove keywords from string
656
+ private void RemoveKeywords ( )
657
+ {
658
+ int current = 0 ;
659
+
660
+ while ( current < ShaderFile . Length )
661
+ {
662
+ if ( ShaderFile . Length >= current + 3 && ShaderFile [ current ] == '#' && ShaderFile [ current + 1 ] == 'K' &&
663
+ ShaderFile [ current + 2 ] == '#' )
664
+ {
665
+ int end = current + 3 ;
666
+ bool stillToRemove = true ;
667
+ while ( end < ShaderFile . Length )
668
+ {
669
+ if ( char . IsWhiteSpace ( ShaderFile [ end ] ) )
670
+ {
671
+ ShaderFile . Remove ( current , end - current ) ;
672
+ stillToRemove = false ;
673
+ break ;
674
+ }
675
+
676
+ end ++ ;
677
+ }
678
+ if ( stillToRemove )
679
+ ShaderFile . Remove ( current , end - current ) ;
680
+ }
681
+
682
+ current ++ ;
683
+ }
684
+ }
685
+
686
+ // Check a line of the property block
658
687
private static bool CheckPropertyBlockLine ( StringBuilder builder , StringReader reader , string line , ref int tabs , ref bool deleteEmptyLine )
659
688
{
660
689
string ln = null ;
0 commit comments