private void MoveTextToTextTable(StringField stringField, TextTable textTable)
        {
            if (stringField == null || stringField.textTable != null || stringField.stringAsset != null)
            {
                return;
            }
            if (string.IsNullOrEmpty(stringField.text))
            {
                return;
            }
            var fieldName = abbreviateFieldNames
                ? ((stringField.text.Length <= MaxAbbreviationLength) ? stringField.text : stringField.text.Substring(0, MaxAbbreviationLength) + "...")
                : stringField.text;
            var fieldID = textTable.GetFieldID(fieldName);

            if (fieldID == 0)
            {
                textTable.AddField(fieldName);
                var field = textTable.GetField(fieldName);
                field.SetTextForLanguage(0, stringField.text);
                fieldID = textTable.GetFieldID(fieldName);
            }
            stringField.text             = string.Empty;
            stringField.stringAsset      = null;
            stringField.textTable        = textTable;
            stringField.textTableFieldID = fieldID;
        }
Beispiel #2
0
        /// <summary>
        /// If a TextTable Document has been specified, convert the Document to a TextTable.
        /// </summary>
        private void ConvertTextTable(string databaseFilename)
        {
            if (articyData == null || articyData.textTableFields.Count == 0 || string.IsNullOrEmpty(prefs.TextTableDocument))
            {
                return;
            }
            var assetPath = prefs.OutputFolder;

            if (!assetPath.EndsWith("/"))
            {
                assetPath += "/";
            }
            var filename = databaseFilename + "_TextTable";

            assetPath += filename + ".asset";
            TextTable textTable = AssetDatabase.LoadAssetAtPath(assetPath, typeof(TextTable)) as TextTable;

            if (textTable != null && prefs.Overwrite)
            {
                textTable.languages.Clear();
                textTable.fields.Clear();
            }
            if (textTable == null)
            {
                textTable = AssetUtility.CreateAssetWithFilename <TextTable>(assetPath, false);
            }
            if (textTable != null)
            {
                articyData.textTableFields.ForEach(field => textTable.AddField(field));
            }
        }
Beispiel #3
0
 public static void AddQuestTagsToTextTable(string s, TextTable textTable)
 {
     if (textTable == null || !ContainsAnyTag(s))
     {
         return;
     }
     foreach (Match match in Regex.Matches(s, @"\{[^\}]+\}"))
     {
         var tag = match.Value;
         if (IsDynamicTag(tag) || IsIDTag(tag) || tag.Length < 2)
         {
             continue;
         }
         var fieldName = tag.Substring(1, tag.Length - 2);
         if (!textTable.HasField(fieldName))
         {
             textTable.AddField(fieldName);
         }
     }
 }