// 从文件中添加资源 public static UITextureAtlas AddTextureAtlasFromFile(string[] spriteNames, string Path) { createStaticAtlas(); Texture2D[] textures = new Texture2D[spriteNames.Length]; for (int i = 0; i < spriteNames.Length; i++) { textures[i] = MUIUtil.loadTextureFromFile(Path + spriteNames[i] + ".png"); textures[i].name = spriteNames[i]; } AddTextures(textures); //Rect[] regions = new Rect[spriteNames.Length]; //regions = ((Texture2D)(m_atlas.material.mainTexture)).PackTextures(textures, 2, 1024); //for (int i = 0; i < spriteNames.Length; i++) //{ // UITextureAtlas.SpriteInfo item = new UITextureAtlas.SpriteInfo // { // name = spriteNames[i], // texture = textures[i], // region = regions[i], // }; // m_atlas.AddSprite(item); //} return(m_atlas); }
public static void AddTextureSpriteInfoFromFile(string spriteName, string file, RectOffset Border) { Texture2D texture = MUIUtil.loadTextureFromFile(file); if (texture == null) { return; } UITextureAtlas.SpriteInfo sprite = new UITextureAtlas.SpriteInfo { name = spriteName, texture = texture, border = Border }; AddTextureSpriteInfo(sprite); }
void UpdateStates(States s) { var color = win.titleColor; // MUISkin.config.titlebarColor; if ((s & States.HoverInTitlebar) == States.HoverInTitlebar) { color = MUIUtil.BrightenColor(color, 0.2f, color[3]); titleTextture.SetPixel(0, 0, color); titleStyle.normal.textColor = MUISkin.config.titleTextHoverColor; } else { titleTextture.SetPixel(0, 0, color); titleStyle.normal.textColor = MUISkin.config.titleTextColor; } color = win.backgroundColor; if (color == Color.clear) { color = Color.gray; color[3] = 0.5f; // alpha } if ((s & States.HoverInResize) == States.HoverInResize) { color = MUIUtil.BrightenColor(color, 0.8f, 1.0f); } else { color = MUIUtil.BrightenColor(color, 0.5f, color[3]); } if (MUISkin.isStyleExists("button_resize")) { resizeTextture = MUISkin.skin.FindStyle("button_resize").normal.background; } else { resizeTextture.SetPixel(0, 0, color); } color = new Color(0.8f, 0.0f, 0.0f, MUISkin.config.titlebarColor[3]); if ((s & States.HoverInCloseButton) == States.HoverInCloseButton) { closeTextture.SetPixel(0, 0, MUIUtil.BrightenColor(color, 0.65f, 1.0f)); if (MUISkin.isStyleExists("button_close")) { closeTextture = MUISkin.skin.FindStyle("button_close").hover.background; } } else { closeTextture.SetPixel(0, 0, color); if (MUISkin.isStyleExists("button_close")) { closeTextture = MUISkin.skin.FindStyle("button_close").normal.background; } } _states = s; titleTextture.Apply(); closeTextture.Apply(); resizeTextture.Apply(); }