public CanvasText AddText(string name, string text, Vector2 pos, Vector2 sz, Font font, int fontSize = 13, FontStyle style = FontStyle.Normal, TextAnchor alignment = TextAnchor.UpperLeft)
        {
            CanvasText t = new CanvasText(canvas, position + pos, sz, font, text, fontSize, style, alignment);

            texts.Add(name, t);

            return(t);
        }
예제 #2
0
        public static void BuildMenu(GameObject canvas)
        {
            panel = new CanvasPanel(canvas, new Texture2D(1, 1), new Vector2(0, 0), Vector2.zero, new Rect(0, 0, 1, 1));
            var tex = GUIController.Instance.images["hidebtnbg"];

            panel.AddButton("hide", tex, new Vector2((1920 - 790) / 2, 10), Vector2.zero, HideClicked, new Rect(0, 0, tex.width, tex.height), GUIController.Instance.arial, "<", 25);

            desc_panel = panel.AddPanel("DescArea", new Texture2D(1, 1), new Vector2(0, 300), new Vector2(1, 1), new Rect(0, 0, 1, 1));

            desc = desc_panel.AddText("Desc", "This is a Description", Vector2.zero, Vector2.zero, GUIController.Instance.arial, 26);
            ItemManager.Instance.OnChanged += ChangeDesc;
            Logger.LogDebug("DescPanel Built");
        }
예제 #3
0
        public static void ChangeDesc(CustomDecoration d)
        {
            string desc = null;

            if (Language.Language.CurrentLanguage() == Language.LanguageCode.ZH)
            {
                var cn = d.GetType().GetCustomAttributes(typeof(DescriptionAttribute), false).OfType <DescriptionAttribute>().Where(x => x.IsChinese()).FirstOrDefault();
                if (cn == null)
                {
                    desc = "该物品没有相关说明";
                }
                else
                {
                    desc = cn.Text;
                }

                desc = $"{desc}\n\n属性说明:\n";

                var desc_prop = d.item.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)
                                .Where(x => x.GetCustomAttributes(typeof(DescriptionAttribute), true).OfType <DescriptionAttribute>()
                                       .Where(y => y.IsChinese()).Any());
                foreach (var p in desc_prop)
                {
                    var prop_text = p.GetCustomAttributes(typeof(DescriptionAttribute), true).OfType <DescriptionAttribute>().FirstOrDefault().Text;
                    var prop_name = p.Name;
                    desc += $"{prop_name}:{prop_text}\n";
                }
            }
            else
            {
                var en = d.GetType().GetCustomAttributes(typeof(DescriptionAttribute), false).OfType <DescriptionAttribute>().Where(x => !x.IsChinese()).FirstOrDefault();
                if (en == null)
                {
                    desc = "there is no description for this item";
                }
                else
                {
                    desc = en.Text;
                }
            }
            UpdateDesc(desc);
            //Logger.LogDebug($"Desc:{desc}");
        }