public static Emoticon Emoticon(string name, float emoticonWidth, float emoticonHeight, UIBaseInfoLoader baseInfoLoder, float[] delays) { GameObject gameObject = new GameObject(name); Emoticon emoticon = gameObject.AddComponent <Emoticon>(); emoticon.SetDelay(delays); emoticon.SetUseBoxCollider(false); emoticon.gameObject.layer = GUICamera.UILayer; emoticon.SetAnchor(SpriteRoot.ANCHOR_METHOD.UPPER_LEFT); emoticon.AutoAnimatorStop = false; if (baseInfoLoder != null) { emoticon.SetSpriteTile(baseInfoLoder.Tile, baseInfoLoder.UVs.width / (float)baseInfoLoder.ButtonCount, baseInfoLoder.UVs.height); Material material = (Material)CResources.Load(baseInfoLoder.Material); emoticon.Setup(emoticonWidth, emoticonHeight, material); float pixelToUVsWidth = UIBaseFileManager.GetPixelToUVsWidth(material, baseInfoLoder.UVs.width / (float)baseInfoLoder.ButtonCount); Rect uvs = new Rect(UIBaseFileManager.GetPixelToUVsWidth(material, baseInfoLoder.UVs.x) - pixelToUVsWidth, 1f - UIBaseFileManager.GetPixelToUVsHeight(material, baseInfoLoder.UVs.y + baseInfoLoder.UVs.height), pixelToUVsWidth, UIBaseFileManager.GetPixelToUVsHeight(material, baseInfoLoder.UVs.height)); for (int i = 0; i < 3; i++) { emoticon.States[i].spriteFrames = new CSpriteFrame[1]; emoticon.States[i].spriteFrames[0] = new CSpriteFrame(); uvs.x += pixelToUVsWidth; emoticon.States[i].spriteFrames[0].uvs = uvs; emoticon.animations[i] = new UVAnimation(); emoticon.animations[i].SetAnim(emoticon.States[i], i); } emoticon.autoResize = false; } return(emoticon); }
public static Emoticon EmoticonCharChat(string name, float emoticonWidth, float emoticonHeight, string emoticonKey) { GameObject gameObject = new GameObject(name); Emoticon emoticon = gameObject.AddComponent <Emoticon>(); emoticon.SetUseBoxCollider(false); emoticon.gameObject.layer = GUICamera.UILayer; emoticon.SetAnchor(SpriteRoot.ANCHOR_METHOD.UPPER_LEFT); emoticon.AutoAnimatorStop = false; UIEmoticonInfo uIEmoticonInfo = NrTSingleton <UIEmoticonManager> .Instance.FindUIEmoticonDictionary(emoticonKey); if (uIEmoticonInfo != null) { emoticon.SetDelay(uIEmoticonInfo.delays); UIBaseInfoLoader infoLoader = uIEmoticonInfo.infoLoader; if (infoLoader == null) { return(emoticon); } emoticon.SetSpriteTile(infoLoader.Tile, infoLoader.UVs.width / (float)infoLoader.ButtonCount, infoLoader.UVs.height); Material material = (Material)CResources.Load(infoLoader.Material); emoticon.Setup(emoticonWidth, emoticonHeight, material); float pixelToUVsWidth = UIBaseFileManager.GetPixelToUVsWidth(material, infoLoader.UVs.width / (float)infoLoader.ButtonCount); Rect uvs = new Rect(UIBaseFileManager.GetPixelToUVsWidth(material, infoLoader.UVs.x) - pixelToUVsWidth, 1f - UIBaseFileManager.GetPixelToUVsHeight(material, infoLoader.UVs.y + infoLoader.UVs.height), pixelToUVsWidth, UIBaseFileManager.GetPixelToUVsHeight(material, infoLoader.UVs.height)); for (int i = 0; i < 3; i++) { emoticon.States[i].spriteFrames = new CSpriteFrame[1]; emoticon.States[i].spriteFrames[0] = new CSpriteFrame(); uvs.x += pixelToUVsWidth; emoticon.States[i].spriteFrames[0].uvs = uvs; emoticon.animations[i].SetAnim(emoticon.States[i], i); } emoticon.autoResize = false; } return(emoticon); }