Exemplo n.º 1
0
    // Called by RuntimeTextEdit when an edit was made. In this method the text is saved into the JSON file. textCompID is used to differentiate which text component was changed.
    public void PersistText(string newText, int textCompID)
    {
        // TextMeshPro component
        if (textMeshProComponent.GetInstanceID() == textCompID)
        {
            textMeshProText.text = newText;
            string json = JsonUtility.ToJson(textMeshProText);
            System.IO.File.WriteAllText(filePathTextMeshProText, json);
        }

        // Unity text component
        if (unityTextComponent.GetInstanceID() == textCompID)
        {
            unityText.text = newText;
            string json = JsonUtility.ToJson(unityText);
            System.IO.File.WriteAllText(filePathUnityText, json);
        }
    }