Beispiel #1
0
 /// <summary>
 /// 异步获取CMAtlas回调
 /// </summary>
 /// <param name="atlas"></param>
 /// <param name="param1"></param>
 /// <param name="parma2"></param>
 /// <param name="param3"></param>
 private static void OnGetCMAtlasAsynDlg(IUIAtlas atlas, object param1, object param2, object param3)
 {
     if (null != param1 && param1 is UISprite)
     {
         UISprite sprite = (UISprite)param1;
         UIAtlas  atl    = (null != atlas) ? atlas.GetAtlas() : null;
         sprite.atlas = atl;
         if (null != param2 && param2 is string)
         {
             sprite.spriteName = (string)param2;
         }
         if (null != param3 && param3 is bool)
         {
             bool makePerfect = (bool)param3;
             if (null != sprite && makePerfect)
             {
                 sprite.MakePixelPerfect();
             }
         }
     }
 }
Beispiel #2
0
    void OnGetAtlas(IUIAtlas cmatlas, object param1, object param2, object param3)
    {
        if (null == cmatlas)
        {
            return;
        }
        UIAtlas atlas = cmatlas.GetAtlas();

        if (null == atlas)
        {
            return;
        }
        if (null != param1 && param1 is UISprite)
        {
            UISprite sprite = (UISprite)param1;
            UIAtlas  atl    = (null != atlas) ? cmatlas.GetAtlas() : null;
            sprite.atlas = atl;
            if (null != param2 && param2 is string)
            {
                sprite.spriteName = (string)param2;
            }
            if (null != param3 && param3 is bool)
            {
                bool makePerfect = (bool)param3;
                if (null != sprite && makePerfect)
                {
                    sprite.MakePixelPerfect();
                }
            }
        }

        if (ani != null)
        {
            ani.RebuildSpriteList();
            ani.Play();
        }
    }
Beispiel #3
0
    private void OnGetEmojiAtlas(IUIAtlas cmatlas, object param1, object param2, object param3)
    {
        if (null == cmatlas)
        {
            return;
        }
        UIAtlas atlas = cmatlas.GetAtlas();

        if (null == atlas)
        {
            return;
        }

        List <UISpriteData> spritedata = atlas.spriteList;

        spritedata.Sort(SortByName);

        Dictionary <string, string> spriteDic = new Dictionary <string, string>();
        List <string> spriteNameList          = new List <string>();

        foreach (var item in spritedata)
        {
            int index = item.name.LastIndexOf('_');//3_3
            if (index != -1)
            {
                string strtype = item.name.Substring(0, index);
                if (spriteDic.ContainsKey(strtype) == false)
                {
                    spriteNameList.Add(strtype + "_1");
                    spriteDic[strtype] = strtype + "_1";
                }
            }
        }

        Debug.Log("emoji count  :" + spriteDic.Count);

        //设置最大表情数
        DataManager.Manager <ChatDataManager>().EmojiMaxNum = spriteDic.Count;

        for (int i = 0; i < spriteNameList.Count; i++)
        {
            int x = i / 4;
            int y = i % 4;

            GameObject go = GameObject.Instantiate(m_sprite_Emoji.gameObject) as GameObject;
            go.transform.parent             = m_trans_Root;
            go.transform.localScale         = Vector3.one;
            go.transform.localPosition      = new Vector3(x * 60, y * (-60), 0);
            UIEventListener.Get(go).onClick = OnClickFaceItem;

            UISprite sprite = go.GetComponent <UISprite>();
            sprite.atlas      = atlas;
            sprite.name       = spriteNameList[i];
            sprite.spriteName = spriteNameList[i];

            sprite.MakePixelPerfect();
            if (sprite.width < 50)
            {
                sprite.width = 50;
            }
            if (sprite.height < 50)
            {
                sprite.height = 50;
            }
        }
    }