Skip to content

How to choose other property if property doesn't exist? #438

Answered by KamilTheDev
KamilTheDev asked this question in Q&A
Discussion options

You must be logged in to vote

Here's what I came up with:

using System;
using SmartFormat;
using SmartFormat.Core.Extensions;
using SmartFormat.Core.Formatting;
using UnityEngine;
using Debug = UnityEngine.Debug;

public class FallbackFormatter : IFormatter, ISource
{
    public string Name { get; set; } = "fallback";

    public bool CanAutoDetect { get; set; } = false;

    public bool TryEvaluateFormat(IFormattingInfo formattingInfo)
    {
        Debug.Log("fallback TryEvaluateFormat called");

        // Replace escaped split characters with a placeholder
        string placeholder = "\uE000"; // Use a Unicode private use area character as a placeholder
        string options = formattingInfo.FormatterOptions.Rep…

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@KamilTheDev
Comment options

@axunonb
Comment options

@axunonb
Comment options

@KamilTheDev
Comment options

Answer selected by axunonb
@axunonb
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants