public CustomDecoration Select(int idx) { if (!setupMode) { return(null); } if (currentSelect != null) { return(currentSelect.GetComponent <CustomDecoration>()); } if (idx < 1 || idx > group[CurrentGroup].Length) { return(null); } string poolname = group[CurrentGroup][idx - 1]; GameObject go = ObjectLoader.CloneDecoration(poolname); currentSelect = go; CustomDecoration cd = go?.GetComponent <CustomDecoration>(); go?.SetActive(true); OnChanged?.Invoke(cd); return(cd); }
private static void Instance_OnChanged(CustomDecoration d) { if (IsToggle()) { Hide(); Show(); } }
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}"); }