Example #1
0
        private void UpdateReplaceList(bool isForce = false)
        {
            if (isForce == false && _statusList.Any(status => status.IsUpdateText) == false)
            {
                // 更新なし
                return;
            }

            var texts = new string[_statusList.Count * ReplaceProperty.Length];

            for (int i = 0; i < _statusList.Count; ++i)
            {
                _statusList[i].IsUpdateText = false;

                var index = i * ReplaceProperty.Length;
                for (int j = 0; j < ReplaceProperty.Length; ++j)
                {
                    texts[index + j] = _statusList[i].GetProperty(ReplaceProperty[j]).stringValue;
                }
            }

            var words = ReplaceProcessor.GetReplaceWords(texts);

            foreach (var status in _statusList)
            {
                TemplateSettingEditor.RemoveChainWords(words, status.TargetTemplateSetting.Chain);
            }

            _replaceList = TemplateSettingEditor.CreateReplaceList(_replaceList, words.ToArray());

            TemplateSettingEditor.SetReplaceListFromConfigValue(_replaceList, _groupSetting.GetInstanceID().ToString());
        }
        protected string ReplaceCode(ProcessDictionary result)
        {
            object obj;

            result.TryGetValue(result.GetLastConvertReplaceWord(TemplateSetting.ResultKey), out obj);
            var setting = obj as TemplateSetting;

            if (setting == null)
            {
                Debug.LogErrorFormat("Not {0} object", TemplateSetting.ResultKey);
                return(null);
            }

            var status = new TemplateSettingStatus(new SerializedObject(setting));

            TemplateSettingEditor.ExecuteChain(status, result);
            var words = ReplaceProcessor.GetReplaceWords(
                status.GetProperty(TemplateSettingStatus.Property.Path).stringValue,
                status.GetProperty(TemplateSettingStatus.Property.ScriptName).stringValue,
                status.GetProperty(TemplateSettingStatus.Property.Code).stringValue
                );
            var replaces = TemplateSettingEditor.CreateReplaceList(new List <ReplaceInfo>(0), words.ToArray());

            foreach (var replace in replaces)
            {
                result.Add(replace.Key, replace.ReplaceWord);
            }

            return(TemplateSettingEditor.Replace(
                       status.GetProperty(TemplateSettingStatus.Property.Code).stringValue,
                       result
                       ));
        }