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()); }
public static string Replace(string text, Dictionary <string, object> result) { return(ReplaceProcessor.ReplaceProcess( text, result )); }
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 )); }
private void UpdateReplaceList(bool isForce = false) { if (isForce == false && SettingStatus.IsUpdateText == false) { // 更新なし return; } SettingStatus.IsUpdateText = false; var words = ReplaceProcessor.GetReplaceWords( SettingStatus.GetProperty(TemplateSettingStatus.Property.Path).stringValue, SettingStatus.GetProperty(TemplateSettingStatus.Property.ScriptName).stringValue, SettingStatus.GetProperty(TemplateSettingStatus.Property.Code).stringValue ); RemoveChainWords(words, SettingStatus.TargetTemplateSetting.Chain); _replaceList = CreateReplaceList(_replaceList, words.ToArray()); SetReplaceListFromConfigValue(_replaceList, _instanceId); }
public static void DrawChain(TemplateSettingStatus status) { EditorGUILayout.BeginVertical(EditorGUIHelper.GetScopeStyle()); { status.ChainReorderableList.DoLayoutList(); var selectIndex = status.ChainReorderableList.index; if (selectIndex >= 0) { var select = status.ChainReorderableList.serializedProperty.GetArrayElementAtIndex(selectIndex); var chain = TemplateUtility.ConvertProcessChianInstanceFromObject(select.objectReferenceValue); if (chain != null) { var builder = new StringBuilder(); builder.AppendLine("[Used Variables]"); foreach (var word in chain.GetReplaceWords()) { builder.AppendLine(ReplaceProcessor.GetReplaceText(word)); } // TODO : Cache var style = new GUIStyle(GUI.skin.label) { wordWrap = true, }; var label = builder.ToString(); var content = new GUIContent(label); var rect = GUILayoutUtility.GetRect(content, style); EditorGUI.SelectableLabel(rect, label, style); EditorGUILayout.LabelField("[Description]\n" + chain.GetDescription(), style); } } else { EditorGUILayout.HelpBox("When you select item, description will be displayed", MessageType.Info, true); } } EditorGUILayout.EndVertical(); }
public static void DrawReplace(List <ReplaceInfo> replaces, string savePrefix) { EditorGUILayout.BeginVertical(EditorGUIHelper.GetScopeStyle()); if (replaces.Count == 0) { EditorGUILayout.HelpBox("{<Foo>} in 'Create Path' and 'Script Name' and 'Code' will be replace\nNote: Variables used in 'Pre Process' are not listed here.", MessageType.Info); } else { foreach (var replace in replaces) { var str = EditorGUILayout.TextField(ReplaceProcessor.GetReplaceText(replace.Key), replace.ReplaceWord); if (str == replace.ReplaceWord) { continue; } // 置き換え文字をUnityへキャッシュ replace.ReplaceWord = str; TemplateUtility.SetConfigValue(savePrefix + replace.Key, replace.ReplaceWord); } } EditorGUILayout.EndVertical(); }