public void Bind(IColorElement colorElement) { var languageService = ShaderLabLanguage.Instance.LanguageService(); Assertion.AssertNotNull(languageService, "languageService != null"); var lexer = languageService.GetPrimaryLexerFactory().CreateLexer(new StringBuffer( $"({colorElement.RGBColor.R/255.0:0.##}, {colorElement.RGBColor.G/255.0:0.##}, {colorElement.RGBColor.B/255.0:0.##}, {colorElement.RGBColor.A/255.0:0.##})")); var parser = (IShaderLabParser)languageService.CreateParser(lexer, null, null); var newLiteral = parser.ParseColorLiteral(); myColorPropertyValue?.SetColor(newLiteral); myColorValue?.SetConstant(newLiteral); }
public void Bind(IColorElement colorElement) { var languageService = ShaderLabLanguage.Instance.LanguageService(); Assertion.AssertNotNull(languageService, "languageService != null"); var formattedString = GetFormattedString(colorElement); var lexer = languageService.GetPrimaryLexerFactory().CreateLexer(new StringBuffer(formattedString)); var parser = (IShaderLabParser)languageService.CreateParser(lexer, null, null); var newLiteral = parser.ParseColorLiteral(); myColorPropertyValue?.SetColor(newLiteral); myColorValue?.SetConstant(newLiteral); }