public void Process(AssetImporter importer, TextWriter writer) { if (Path.GetExtension(importer.assetPath) != ".prefab") { return; } var go = AssetDatabase.LoadAssetAtPath <GameObject>(importer.assetPath); var bindings = go.GetComponentsInParent <LuaBinding>(); foreach (var binding in bindings) { foreach (var data in binding.LuaData) { if (!(data is LuaBindingAssetReferenceData refData) || refData.Data.GUIDValid) { continue; } writer.WriteLine($"ERROR\t{importer.assetPath}:{UIEditorUtil.RecursiveNodePath(binding.transform)} Lua Binding Asset Reference is missing"); } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var rect = position; rect.height = EditorGUIUtility.singleLineHeight; EditorGUI.LabelField(rect, "Key", property.stringValue); rect.y += UIEditorUtil.LINE_HEIGHT; if (string.IsNullOrEmpty(m_text) && !string.IsNullOrEmpty(property.stringValue)) { m_text = FindGUID(property.stringValue); } rect.height = UIEditorUtil.LINE_HEIGHT * 2 + EditorGUIUtility.singleLineHeight; m_text = EditorGUI.TextArea(rect, m_text); rect.y += UIEditorUtil.LINE_HEIGHT * 3; rect.height = EditorGUIUtility.singleLineHeight; var applyRect = UIEditorUtil.CalcMultiColumnRect(rect, 0, 2); if (GUI.Button(applyRect, "Apply To Config")) { var guid = property.stringValue; if (string.IsNullOrEmpty(guid)) { guid = FindGUID(m_text); } if (string.IsNullOrEmpty(guid)) { guid = GUID.Generate().ToString(); property.stringValue = guid; NewElement(guid); } else { bool found = false; foreach (XmlElement i18nElement in m_rootElement) { if (i18nElement.GetAttribute("guid") == guid) { i18nElement.Attributes[DEFAULT_EDITOR_LANG].Value = m_text; m_i18nXml.Save(xmlConfigPath); var t = m_existTexts.Find(text => text.GUID == guid); if (t == null) { m_existTexts.Add(new StaticText() { Text = m_text, GUID = guid }); } else { t.Text = m_text; } found = true; break; } } if (!found) { NewElement(guid); } } var component = property.serializedObject.targetObject as Component; if (component) { var textMesh = component.GetComponent <TextMeshProUGUI>(); if (textMesh) { textMesh.text = m_text; } var txt = component.GetComponent <Text>(); if (txt) { txt.text = m_text; } } } var cancelRect = UIEditorUtil.CalcMultiColumnRect(rect, 1, 2); if (GUI.Button(cancelRect, "Cancel")) { var guid = property.stringValue; if (string.IsNullOrEmpty(guid)) { m_text = string.Empty; return; } var elements = m_rootElement.GetElementsByTagName(guid); if (elements.Count != 0) { var element = elements[0] as XmlElement; m_text = element.Attributes[DEFAULT_EDITOR_LANG].Value; } } }