Beispiel #1
0
    protected override void Start()
    {
        base.Start();
#if UNITY_EDITOR
        if (!Application.isPlaying)
        {
            return;
        }
#endif
        Factory = FactoryManager.GetFactory();
        if (TextManager == null)
        {
            TextManager = Factory.GetResource <UITextManager>("UITextManager");
        }
        UIText uiText = TextManager.FixedText[Index];
        if (uiText.TraditionalChineses.Count == 1 && !uiText.TraditionalChineses[0].Contains("{0}"))
        {
            switch (Language)
            {
            case Language.TraditionalChinese:
                this.text = uiText.TraditionalChineses[0];
                break;

            case Language.SimplifiedChinese:
                this.text = uiText.SimplifiedChineses[0];
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
    }
Beispiel #2
0
    public static void RefreshText()
    {
        string[]          sdirs       = { "Assets/Art/UIPrefab", "Assets/Editor Default Resources" };
        var               asstIds     = AssetDatabase.FindAssets("t:Prefab", sdirs);
        List <GameObject> gameObjects = new List <GameObject>();

        foreach (var asstId in asstIds)
        {
            string path = AssetDatabase.GUIDToAssetPath(asstId);
            var    pfb  = AssetDatabase.LoadAssetAtPath <GameObject>(path);
            gameObjects.Add(pfb);
        }
        int           i     = 0;
        List <UIText> texts = new List <UIText>();

        foreach (var pfb in gameObjects)
        {
            foreach (var text in pfb.GetComponentsInChildren <MyText>(true))
            {
                bool       exist = false;
                GameObject go    = null;
                foreach (var mono in pfb.GetComponentsInChildren <MonoBehaviour>(true))
                {
                    foreach (var field in mono.GetType().GetFields())
                    {
                        var xx = mono.GetFieldByReflect(field.Name);
                        if (xx.IsNotNull() && xx.GetType() == typeof(MyText))
                        {
                            if (xx.As <MyText>() == text)
                            {
                                go    = mono.gameObject;
                                exist = true;
                                break;
                            }
                        }
                    }
                }
                if (!exist && text.GetComponent("TextAdapt") == null)
                {
                    texts.Add(GetText(true, i, pfb.name, text));
                }
                else
                {
                    texts.Add(GetText(false, i, go?.gameObject.name, text));
                }
                text.Index = i;
                i++;
            }
            try
            {
                PrefabUtility.SavePrefabAsset(pfb);
            }
            catch (Exception e)
            {
                Debug.LogWarning(e.Message);
            }
        }

        //excel文本

        ExcelTool excelTool = new ExcelTool(true);
        PropertyExcelTextManager propertyExcelTextManager = ScriptableObject.CreateInstance <PropertyExcelTextManager>();

        propertyExcelTextManager.PropertyExcelText = excelTool.CreatePropertyExcelTextArrayWithExcel(propertyExcelTextManager);
        List <UIText>     excelTexts = new List <UIText>();
        LanguageTranslate translate  = new LanguageTranslate();

        for (int j = 0; j < propertyExcelTextManager.PropertyExcelText.Length; j++)
        {
            excelTexts.Add(new UIText()
            {
                Fixed              = true,
                Index              = j,
                Name               = DataEncryptManager.StringDecoder(propertyExcelTextManager.PropertyExcelText[j].ConstKey),
                ParentName         = "Excel",
                SimplifiedChineses = new List <string>()
                {
                    translate.ConvertChinSimp(propertyExcelTextManager.PropertyExcelText[j].ConstValue)
                },
                TraditionalChineses = new List <string>()
                {
                    translate.ConvertChinTrad(propertyExcelTextManager.PropertyExcelText[j].ConstValue)
                },
            });
        }
        UITextManager textManager = new UITextManager
        {
            FixedText = texts,
            ExcelText = excelTexts
        };

        AssetDatabase.CreateAsset(textManager, $"{ExcelConfig.assetPath}UITextManager.asset");
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
Beispiel #3
0
 public static void refreshData()
 {
     UITextMap = new Dictionary <long, UITextBean>();
     UITextMap = UITextManager.LoadAllUIText();
 }
Beispiel #4
0
 void Start()
 {
     _instance = this;
     _preTime  = Time.time;
     textSet   = new Queue <string>();
 }