Beispiel #1
0
        private static void CheckLocalizedTextInPrefab(GameObject obj, string assetName, LanguageSource source)
        {
            var  components = obj.GetComponentsInChildren <LocalizedText>(true);
            bool modifyTag  = false;

            foreach (var component in components)
            {
                string text = GetComponentText(component.gameObject);
                if (text.Length > 0)
                {
                    var tComponent = component.gameObject.GetComponent <Text>();
                    if (!StringUtil.ContainChinese(text))  // 不包含汉字
                    {
                        ModifyLocalizedText(component, "", "");
                        modifyTag = true;
                    }
                    else
                    {
                        uint key = StringUtil.ToUInt32(assetName + text);
                        if (!key.Equals(component.Key) || !assetName.Equals(component.AssetName))
                        {
                            ModifyLocalizedText(component, key.ToString(), assetName);
                            modifyTag = true;
                        }
                        if (!source.ContainEntry(key))
                        {
                            source.AddEntry(new LanguageEntry(key, text));
                        }
                    }

                    if (modifyTag)
                    {
                        PrefabUtility.SavePrefabAsset(obj);
                    }
                }
            }
        }