public virtual ExpressionSyntax Constant(object value, Stencil stencil, Type generatedType = null) { switch (value) { case float f: return(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(f))); case decimal d: return(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(d))); case int i: return(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(i))); case double d: return(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(d))); case bool b: return(LiteralExpression(b ? SyntaxKind.TrueLiteralExpression : SyntaxKind.FalseLiteralExpression)); case string s: return(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(s))); case char c: return(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(c))); case Vector2 _: case Vector3 _: case Vector4 _: case Quaternion _: case Color _: if (generatedType == null) { generatedType = value.GetType(); } return(RoslynBuilder.CreateConstantInitializationExpression(value, generatedType)); case Enum _: return(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, IdentifierName(value.GetType().Name), IdentifierName(value.ToString()) )); case EnumValueReference e: return(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, TypeSystem.BuildTypeSyntax(e.EnumType.Resolve(stencil)), IdentifierName(e.ValueAsEnum(stencil).ToString()) )); case AnimationCurve _: return(DefaultExpression(TypeSyntaxFactory.ToTypeSyntax(typeof(AnimationCurve)))); case LayerMask m: return(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(m.value))); case InputName inputName: return(inputName.name == null ? LiteralExpression(SyntaxKind.NullLiteralExpression) : LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(inputName.name))); case SceneAsset asset: return(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(AssetDatabase.GetAssetPath(asset)))); default: return(DefaultExpression(TypeSystem.BuildTypeSyntax(value.GetType()))); } }