void SendInput() { string text = textInput.text; EmojiTools.Parse(richTextField, text); //富文本解析string 替换emoji textInput.text = ""; }
void Start() { UIPackage.AddPackage("UI/EmojiDemo/EmojiDemo"); GRoot.inst.SetContentScaleFactor(1080, 1920, UIContentScaler.ScreenMatchMode.MatchWidthOrHeight); view = UIPackage.CreateObject("EmojiDemo", "EmojiDemo").asCom; view.SetSize(GRoot.inst.width, GRoot.inst.height); view.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(view); richTextField = view.GetChild("richtext").asRichTextField; string text = "An awesome string with a few 😉emojis!"; EmojiTools.Parse(richTextField, text); textInput = view.GetChild("input").asTextInput; textInput.onFocusOut.Set(() => { SendInput(); }); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity <Guild>(guild => { guild.HasKey(x => x.Id); guild.Property(x => x.Language) .HasConversion(x => x.CultureCode, x => _localization.Languages .First(y => y.CultureCode.Equals(x))); guild.Property(x => x.CustomPrefixes).HasDefaultValueSql("'{}'"); guild.Property(x => x.BlacklistedModmailAuthors) .HasConversion(new SnowflakeCollectionConverter()) .HasDefaultValueSql("''"); guild.Property(x => x.BlacklistedEmojiGuilds) .HasConversion(new SnowflakeCollectionConverter()) .HasDefaultValueSql("''"); guild.Property(x => x.BlacklistedStarboardIds) .HasConversion(new SnowflakeCollectionConverter()) .HasDefaultValueSql("''"); }); modelBuilder.Entity <GlobalUser>(user => { user.HasKey(x => x.Id); user.Property(x => x.Language) .HasConversion(x => x.CultureCode, x => _localization.Languages .First(y => y.CultureCode.Equals(x))); user.Property(x => x.PreviousNames) .HasDefaultValueSql("'{}'"); user.Property(x => x.HighlightBlacklist) .HasConversion(new SnowflakeCollectionConverter()) .HasDefaultValueSql("''"); }); modelBuilder.Entity <GuildUser>(user => { user.HasKey(x => new { x.Id, x.GuildId }); user.Property(x => x.PreviousNames) .HasDefaultValueSql("'{}'"); }); modelBuilder.Entity <Punishment>(punishment => { punishment.HasKey(x => x.Id); punishment.Property(x => x.Id).ValueGeneratedOnAdd(); punishment.Property(x => x.Image).HasConversion(x => x.ToArray(), x => new MemoryStream(x)); }); modelBuilder.Entity <Kick>(kick => { kick.HasBaseType <Punishment>(); }); modelBuilder.Entity <RevocablePunishment>(punishment => { punishment.HasBaseType <Punishment>(); }); modelBuilder.Entity <Ban>(ban => { ban.HasBaseType <RevocablePunishment>(); }); modelBuilder.Entity <Mute>(mute => { mute.HasBaseType <RevocablePunishment>(); }); modelBuilder.Entity <Warning>(warning => { warning.HasBaseType <RevocablePunishment>(); }); modelBuilder.Entity <LoggingChannel>(channel => { channel.HasKey(x => new { x.GuildId, x.Type }); }); modelBuilder.Entity <SpecialRole>(role => { role.HasKey(x => new { x.GuildId, x.Type }); }); modelBuilder.Entity <Modmail>(mail => { mail.HasKey(x => x.Id); mail.Property(x => x.Id).ValueGeneratedOnAdd(); mail.HasMany(x => x.Messages) .WithOne(x => x.Source) .HasForeignKey(x => x.SourceId); }); modelBuilder.Entity <ModmailMessage>(message => { message.HasKey(x => x.Id); message.Property(x => x.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity <WarningPunishment>(punishment => { punishment.HasKey(x => new { x.GuildId, x.Count }); }); modelBuilder.Entity <Permission>(permission => { permission.HasKey(x => x.Id); permission.Property(x => x.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity <Suggestion>(suggestion => { suggestion.HasKey(x => x.Id); suggestion.Property(x => x.Id).ValueGeneratedOnAdd(); suggestion.Property(x => x.Image).HasConversion(x => x.ToArray(), x => new MemoryStream(x)); }); modelBuilder.Entity <SpecialEmoji>(emoji => { emoji.HasKey(x => new { x.GuildId, x.Type }); emoji.Property(x => x.Emoji).HasConversion(new EmojiConverter()) .HasDefaultValueSql("''"); }); modelBuilder.Entity <Highlight>(highlight => { highlight.HasKey(x => x.Id); highlight.Property(x => x.Id) .ValueGeneratedOnAdd(); }); modelBuilder.Entity <ReactionRole>(role => { role.HasKey(x => x.Id); role.Property(x => x.Id) .ValueGeneratedOnAdd(); role.Property(x => x.Emoji) .HasConversion(x => x.ToString(), x => EmojiTools.Parse(x)); }); modelBuilder.Entity <LevelReward>(reward => { reward.HasKey(x => x.Id); reward.Property(x => x.Id) .ValueGeneratedOnAdd(); }); modelBuilder.Entity <RoleLevelReward>(reward => { reward.HasBaseType <LevelReward>(); reward.Property(x => x.AddedRoleIds) .HasConversion(new SnowflakeCollectionConverter()) .HasDefaultValueSql("''"); reward.Property(x => x.RemovedRoleIds) .HasConversion(new SnowflakeCollectionConverter()) .HasDefaultValueSql("''"); }); modelBuilder.Entity <Tag>(tag => { tag.HasKey(x => new { x.GuildId, x.Name }); tag.Property(x => x.Image).HasConversion(x => x.ToArray(), x => new MemoryStream(x)); }); modelBuilder.Entity <Reminder>(reminder => { reminder.HasKey(x => x.Id); reminder.Property(x => x.Id) .ValueGeneratedOnAdd(); }); modelBuilder.Entity <CommandAlias>(alias => { alias.HasKey(x => new { x.GuildId, x.Alias }); }); modelBuilder.Entity <StarboardEntry>(entry => { entry.HasKey(x => x.MessageId); entry.Property(x => x.Stars) .HasConversion(new SnowflakeCollectionConverter()) .HasDefaultValueSql("''"); }); modelBuilder.Entity <CyclingStatus>(status => { status.HasKey(x => x.Id); status.Property(x => x.Id) .ValueGeneratedOnAdd(); }); modelBuilder.Entity <TextChannel>(channel => { channel.HasKey(x => new { x.GuildId, x.ChannelId }); }); modelBuilder.Entity <CommandCooldown>(cooldown => { cooldown.HasKey(x => new { x.GuildId, x.CommandName }); }); modelBuilder.Entity <CooldownData>(data => { data.HasKey(x => new { x.GuildId, x.UserId, x.Command }); }); modelBuilder.Entity <SelfAssignableRole>(role => { role.HasKey(x => new { x.GuildId, x.RoleId }); }); }