Parsing.ParseMaterial C# (CSharp) Method

ParseMaterial() static private method

static private ParseMaterial ( string literal ) : OzmlMaterial,
literal string
return OzmlMaterial,
    static OzmlMaterial ParseMaterial(string literal)
    {
        //Debug.Log("Parsing " + literal + " as Material");

        var result = new OzmlMaterial();

        var bracketStart = literal.IndexOf('{');
        result.Name = literal.Substring(1, bracketStart - 1).Trim();

        var tag = "diffuse:";
        var from = literal.IndexOf(tag, bracketStart) + tag.Length;
        if (from >= tag.Length)
            ParseRgb(literal, ref from, ref result.AmbientDiffuse);

        tag = "specular:";
        from = literal.IndexOf(tag, bracketStart) + tag.Length;
        if (from >= tag.Length)
            ParseRgb(literal, ref from, ref result.Specular);

        tag = "emissive:";
        from = literal.IndexOf(tag, bracketStart) + tag.Length;
        if (from >= tag.Length)
            ParseRgb(literal, ref from, ref result.Emissive);

        tag = "opacity:";
        from = literal.IndexOf(tag, bracketStart) + tag.Length;
        if (from >= tag.Length)
            ParseByte(literal, ref from, ref result.Opacity);

        tag = "power:";
        from = literal.IndexOf(tag, bracketStart) + tag.Length;
        if (from >= tag.Length)
            ParseDecimal(literal, ref from, ref result.Power);

        tag = "texture:";
        from = literal.IndexOf(tag, bracketStart) + tag.Length;
        if (from >= tag.Length)
            result.Texture = literal.Substring( from, literal.IndexOf('}') - from ).Trim();

        return result;
    }