void OnLoadHudAtlas() { if (mAtlasID != 0) { UITexAtlas atlas = CAtlasMng.instance.GetAtlasByID(mAtlasID); if (atlas != null) { m_mat.SetTexture("_MainTex", atlas.mainTexture); m_mat.SetTexture("_MainAlpha", atlas.MainAlphaTexture); m_mat.SetFloat("_ReverseY", GetReserveY()); } } else { if (mFont != null && mFont.material != null) { Material mat = mFont.material; if (m_mat == null) { m_mat = new Material(Shader.Find("Unlit/HUDFont")); } m_mat.mainTexture = mat.mainTexture; m_mat.mainTextureOffset = mat.mainTextureOffset; m_mat.mainTextureScale = mat.mainTextureScale; m_mat.SetFloat("_ReverseY", GetReserveY()); } } }
/// <summary> /// Draw the sprite preview. /// </summary> public override void OnPreviewGUI(Rect rect, GUIStyle background) { // 绘制预览面板 if (mSprite == null || !mSprite.isValid) { return; } if (m_sprite == null) { return; } UISpriteInfo sp = AtlasMng_Editor.instance.GetSprite(mSprite.name); if (sp == null) { return; } UITexAtlas atlas = AtlasMng_Editor.instance.GetAltasBySpriteName(mSprite.name); if (atlas == null || atlas.m_material == null) { return; } Texture2D tex = atlas.m_material.mainTexture as Texture2D; if (tex == null) { return; } Rect outer = new Rect(sp.outer); Rect inner = new Rect(sp.inner); Rect uv = outer; if (atlas.coordinates == UITexAtlas.Coordinates.Pixels) { uv = HUDMath.ConvertToTexCoords(outer, tex.width, tex.height); } else { outer = HUDMath.ConvertToPixels(outer, tex.width, tex.height, true); inner = HUDMath.ConvertToPixels(inner, tex.width, tex.height, true); } HUDEditorTools.DrawSprite(tex, rect, outer, inner, uv, new Color(1.0f, 1.0f, 1.0f, 1.0f)); }
public void InitSprite(int nWidth = 0, int nHeight = 0) { ch = '\0'; AtlasID = -1; UISpriteInfo sp = CAtlasMng.instance.GetSafeSpriteByID(SpriteID); if (sp == null) { return; } AtlasID = sp.m_nAtlasID; width = nWidth <= 0 ? (short)(sp.outer.width + 0.5f) : (short)nWidth; height = nHeight <= 0 ? (short)(sp.outer.height + 0.5f) : (short)nHeight; Scale = 1.0f; Rect mOuterUV = sp.outer; UITexAtlas texAtlas = CAtlasMng.instance.GetAtlasByID(sp.m_nAtlasID); if (texAtlas != null && texAtlas.coordinates == UITexAtlas.Coordinates.Pixels) { mOuterUV = HUDVertex.ConvertToTexCoords(mOuterUV, texAtlas.texWidth, texAtlas.texHeight); } float fL = 0.0f; float fT = 0.0f; float fR = width; float fB = height; vecRU.Set(fR, fT); // 右上角 vecRD.Set(fR, fB); // 右下角 vecLD.Set(fL, fB); // 左下角 vecLU.Set(fL, fT); // 左上角 float uvR = mOuterUV.xMax; float uvL = mOuterUV.xMin; float uvB = mOuterUV.yMin; float uvT = mOuterUV.yMax; uvRU.Set(uvR, uvB); uvRD.Set(uvR, uvT); uvLD.Set(uvL, uvT); uvLU.Set(uvL, uvB); clrLD = clrLU = clrRD = clrRU = Color.white; }
List <SelectSpriteInfo> GetSelectedInfo() { List <SelectSpriteInfo> aSelect = new List <SelectSpriteInfo>(); List <Texture> aTexList = AtlasMng_Editor.GetSelectedTextures(); foreach (Texture o in aTexList) { string szName = AtlasMng_Editor.GetAssetPathByTexture(o); if (!string.IsNullOrEmpty(szName)) { if (szName.IndexOf("Assets/Atlas/") == 0) { continue; } SelectSpriteInfo info = new SelectSpriteInfo(); info.m_szAssetsName = szName; info.m_szSpriteName = AtlasMng_Editor.GetSpriteNameByAssetsName(szName); info.m_szAtlasName = CAtlasMng.instance.GetAtlasNameBySpriteName(info.m_szSpriteName); if (string.IsNullOrEmpty(info.m_szAtlasName)) { info.m_szAtlasName = NGUISettings.atlasName.Trim(); if (string.IsNullOrEmpty(info.m_szAtlasName)) { info.m_szAtlasName = "default"; } } UITexAtlas atlas = CAtlasMng.instance.GetAltas(info.m_szSpriteName); if (atlas != null) { continue; } info.m_sprite = CAtlasMng.instance.GetSprite(info.m_szSpriteName); info.m_selectTex = o; aSelect.Add(info); } } return(aSelect); }
void RenderAllSpriteInfo(ref int nX, ref int nY) { float fx = (float)nX; float fy = (float)nY; float fLineGap = 3.0f; float fBtH = 20.0f; float fBtW = 100.0f; float fTexH = 15.0f; bool bUpdate = false; // 得到当前选中的对象 Color backColor = GUI.backgroundColor; float fButtonX = fx; if (m_nSelectCount > 0) { GUI.backgroundColor = Color.green; if (GUI.Button(new Rect(fButtonX, fy, 100, fBtH), "添加或更新")) { bUpdate = true; } GUI.backgroundColor = Color.white; } else { GUI.Button(new Rect(fButtonX, fy, 100, fBtH), "请先选中图片"); } fButtonX += 100; if (GUI.Button(new Rect(fButtonX, fy, 80, fBtH), "ID排序")) { SortByID(); } fButtonX += 80; if (GUI.Button(new Rect(fButtonX, fy, 80, fBtH), "Name排序")) { SortBySpriteName(); } fButtonX += 80; if (GUI.Button(new Rect(fButtonX, fy, 80, fBtH), "材质名排序")) { SortByAtlasName(); } fButtonX += 80; if (GUI.Button(new Rect(fButtonX, fy, 80, fBtH), "选择排序")) { SortBySelect(); } fButtonX += 80; GUI.Label(new Rect(fButtonX, fy - fBtH - fLineGap, 200, fBtH), "我要搜索(材质名&精灵名)"); string szNewLockSearchName = GUI.TextField(new Rect(fButtonX, fy, 200, fBtH), m_szLockSearchName, 25); if (szNewLockSearchName != m_szLockSearchName) { m_szLockSearchName = szNewLockSearchName; RefresyByLockName(); } fButtonX += 210; UITexAtlas atlas = CAtlasMng.instance.GetAltas(NGUISettings.atlasName); bool bOldLOD = NGUISettings.canLOD; if (atlas != null) { bOldLOD = atlas.IsCanLOD(); } bool bIsCanLOD = GUI.Toggle(new Rect(fButtonX, fy, 100, fBtH), bOldLOD, "图集允许LOD"); if (bIsCanLOD != bOldLOD) { NGUISettings.canLOD = bIsCanLOD; if (atlas != null) { atlas.SetLODFlag(bIsCanLOD); CAtlasMng.instance.SaveAltasCfg(); } } fy += fBtH + fLineGap; // m_szLockSearchName // 开始渲染当前材质的对象了 Rect rc = position; int nScreenW = Screen.width; float fListH = rc.height - fy; float fWindowW = rc.width; int nSelect = -1; bool bDelete = false; SelectSpriteInfo select = null; int nSpriteCount = m_SelectSprite.Count; if (nSpriteCount > 0) { float fSize = fListH; float topValue = 0.0f; float bottomValue = nSpriteCount * (fTexH + fLineGap) + fTexH; Rect rcView = new Rect(fx, fy, fWindowW, fListH); Rect rcRange = new Rect(fx, fy, fWindowW + fx, bottomValue - m_fScrollPos + fTexH); m_vScrollPos = GUI.BeginScrollView(rcView, m_vScrollPos, rcRange, false, false); //m_fScrollPos = GUI.VerticalScrollbar(new Rect(fWindowW - 30, fy, 30, fListH), m_fScrollPos, fSize, topValue, bottomValue); m_fScrollPos = m_vScrollPos.y; int nStartShow = (int)(m_fScrollPos) / (int)(fTexH + fLineGap); float fSpriteWidth = fWindowW * 0.75f; if (nStartShow < 0) { nStartShow = 0; } float x = fx; float y = fy; float fTempY = fy + m_fScrollPos; for (int i = nStartShow; i < nSpriteCount; ++i) { SelectSpriteInfo sp = m_SelectSprite[i]; y = fTempY - m_fScrollPos; float fRight = GetButtonLeft(i, fWindowW - 70); GUI.backgroundColor = GetSpriteButtonColor(i); if (GUI.Button(new Rect(x, y, fRight, fTexH), GUIContent.none)) { m_szSelectSpriteName = sp.m_szSpriteName; sp.m_bCurSelect = true;// !sp.m_bCurSelect; nSelect = i; select = sp; m_pSelectSprite = sp; if (!string.IsNullOrEmpty(sp.m_szAssetsName)) { sp.m_nNextAssetsType++; if (sp.m_nNextAssetsType > 1) { sp.m_nNextAssetsType = 0; } // 输入名字 -- 文件名字,两个做转换 if (sp.m_nNextAssetsType == 0) { sp.m_szAtlasName = NGUISettings.atlasName.Clone() as string; if (string.IsNullOrEmpty(sp.m_szAtlasName)) { sp.m_szAtlasName = sp.m_szSpriteName; NGUISettings.atlasName = sp.m_szAtlasName.Clone() as string; } } else { sp.m_szAtlasName = sp.m_szSpriteName; } } } GUI.backgroundColor = Color.white; //GUI.Label(new Rect(x, y, 30, fTexH), sp.m_nIndex.ToString()); int nSpriteID = sp.m_sprite != null ? sp.m_sprite.m_nNameID : 0; GUI.Label(new Rect(x, y, 30, fTexH), nSpriteID.ToString()); GUI.Label(new Rect(x + 30, y, fSpriteWidth, fTexH), sp.m_szSpriteName); GUI.Label(new Rect(x + fWindowW * 0.5f - 20, y, fWindowW * 0.25f + 40, fTexH), sp.m_szAtlasName); RenderSpriteButton(i, fWindowW - 70, y, ref bDelete); fTempY += fTexH + fLineGap; } GUI.EndScrollView(); } else { } // 处理消息逻辑 if (bDelete || bUpdate || select != null) { if (select != null) { UITexAtlas selectAtlas = CAtlasMng.instance.GetAltasBySpriteName(m_szSelectSpriteName); if (selectAtlas != null) { NGUISettings.atlasPadding = selectAtlas.pixelSize; NGUISettings.atlasTrimming = false; NGUISettings.atlasPMA = selectAtlas.premultipliedAlpha; NGUISettings.atlasName = selectAtlas.m_szAtlasName.Clone() as string; } } OnSpriteOperator(bDelete, bUpdate, select); } }
void RenderAtlasInfo(ref int nX, ref int nY) { nY += 5; float fLineGap = 3.0f; float fBtH = 20.0f; float fBtW = 80.0f; float fTexH = 15.0f; float fx = (float)nX; float fy = (float)nY; float fButtonX = fx; fButtonX += fBtW + 5.0f; NGUISettings.atlasName = GUI.TextField(new Rect(fButtonX, fy, 100.0f, fBtH), NGUISettings.atlasName, 25); fButtonX += 100.0f + 5.0f; bool bModifyAtlas = false; if (GUI.Button(new Rect(fButtonX, fy, fBtW, fBtH), "修改")) { bModifyAtlas = true; } fButtonX += fBtW; bool bRepareAtlas = false; if (GUI.Button(new Rect(fButtonX, fy, fBtW, fBtH), "整理")) { bRepareAtlas = true; } fButtonX += fBtW; bool bExportIcon = false; if (GUI.Button(new Rect(fButtonX, fy, fBtW, fBtH), "导出")) { bExportIcon = true; } //fy += fBtH + fLineGap; fButtonX += fBtW; bool bExportID = false; if (GUI.Button(new Rect(fButtonX, fy, fBtW, fBtH), "导出ID表")) { bExportID = true; } fButtonX += fBtW; fy += fBtH + fLineGap; // 渲染一个数字吧 float x = fx + fBtW; GUI.Label(new Rect(fx, fy, fBtW, fBtH), "Padding"); NGUISettings.atlasPadding = RenderEditorNumb(x, fy, 20, fTexH + 2, NGUISettings.atlasPadding); GUI.Label(new Rect(x + 25, fy, 150, fBtH), "Pixel in-between of sprites"); fy += fTexH + fLineGap; // GUI.Label(new Rect(fx, fy, fBtW, fBtH), "Trim Alpha"); NGUISettings.atlasTrimming = RenderCheckBox(x, fy, 200, fBtH, NGUISettings.atlasTrimming, "Remove empty space"); bool bAdjustAtlas = false; float fLeft = x + 25 + 150 + fBtW; if (GUI.Button(new Rect(x + 25 + 150 + fBtW, fy, fBtW, fBtH), "纠正数据")) { bAdjustAtlas = true; } bool bBinToTxt = false; if (GUI.Button(new Rect(fLeft + fBtW + 5, fy, fBtW * 2, fBtH), "二进制转换文本")) { bBinToTxt = true; } fLeft += fBtW * 2 + 5; bool bTxtToBin = false; if (GUI.Button(new Rect(fLeft + fBtW + 5, fy, fBtW * 2, fBtH), "文本转二进制")) { bTxtToBin = true; } fy += fTexH + fLineGap; GUI.Label(new Rect(fx, fy, fBtW, fBtH), "PMA Shader"); NGUISettings.atlasPMA = RenderCheckBox(x, fy, 200, fBtH, NGUISettings.atlasPMA, "Pre-multiply color by alpha"); if (NGUISettings.atlasPMA) { NGUISettings.atlasPMA = false; EditorUtility.DisplayDialog("警告", "这个已经不支持了,只能选择false", "确定"); } fy += fTexH + fLineGap; GUI.Label(new Rect(fx, fy, fBtW, fBtH), "4096x4096"); NGUISettings.allow4096 = RenderCheckBox(x, fy, 200, fBtH, NGUISettings.allow4096, "if off, limit atlases to 2048x2048"); fy += fTexH + fLineGap; nY = (int)fy; // 渲染材质属性 if (bModifyAtlas) { AtlasMng_Editor.instance.m_lpImportPackTextureFunc = ImportPackTextureFunc; UITexAtlas atlas = AtlasMng_Editor.instance.GetAltas(NGUISettings.atlasName); if (atlas != null) { atlas.pixelSize = NGUISettings.atlasPadding; AtlasMng_Editor.instance.SaveAltasCfg(); } } if (bRepareAtlas) { bool bTrimAlpha = NGUISettings.atlasTrimming; AtlasMng_Editor.instance.m_lpImportPackTextureFunc = ImportPackTextureFunc; if (AtlasMng_Editor.instance.RepareAtlas(NGUISettings.atlasName, bTrimAlpha)) { EditorUtility.DisplayDialog("提示", "整理完毕", "OK"); } else { EditorUtility.DisplayDialog("提示", "整理失败", "OK"); } } if (bExportIcon) { // 导出选选择的图片 string szDefPath = Application.dataPath + "/"; string szPath = EditorUtility.OpenFolderPanel("打开要导出的目录", szDefPath, ""); if (!string.IsNullOrEmpty(szPath)) { szPath = szPath + '/'; AtlasMng_Editor.instance.m_lpImportPackTextureFunc = ImportPackTextureFunc; if (AtlasMng_Editor.instance.ExportSpriteIcon(NGUISettings.atlasName, szPath, ExportTGA)) { EditorUtility.DisplayDialog("提示", "导出完毕", "OK"); } else { EditorUtility.DisplayDialog("提示", "导出失败", "OK"); } } } if (bExportID) { string szDefPath = Application.dataPath + "/"; string[] filters = { ".txt", ".*" }; string szPath = EditorUtility.OpenFolderPanel("打开要导出的目录", szDefPath, ""); //string szPathName = EditorUtility.SaveFilePanel("导出ID文件", szDefPath, "gif_id.txt", "txt"); if (!string.IsNullOrEmpty(szPath)) { szPath = szPath + '/'; string szPathName = szPath + "gif_id.txt"; ExportSelectID(szPathName); } } if (bAdjustAtlas) { if (AtlasMng_Editor.instance.AdjustAtlasData()) { EditorUtility.DisplayDialog("提示", "纠正完毕,已保存", "OK"); } else { EditorUtility.DisplayDialog("提示", "没有需要纠正的数据", "OK"); } } if (bBinToTxt) { AtlasMng_Editor atlasMng = new AtlasMng_Editor(); atlasMng.LoadAndSaveAtlas(false); } if (bTxtToBin) { AtlasMng_Editor atlasMng = new AtlasMng_Editor(); atlasMng.LoadAndSaveAtlas(true); } }
void DrawEditData() { Color blue = new Color(0f, 0.7f, 1f, 1f); Color green = new Color(0.4f, 1f, 0f, 1f); // 绘制预览面板 if (mSprite == null || !mSprite.isValid) { return; } if (m_sprite == null) { return; } UISpriteInfo sprite = AtlasMng_Editor.instance.GetSprite(mSprite.name); if (sprite == null) { return; } UITexAtlas atlas = AtlasMng_Editor.instance.GetAltasBySpriteName(mSprite.name); if (atlas == null) { return; } Rect inner = sprite.inner; Rect outer = sprite.outer; if (atlas.coordinates == UITexAtlas.Coordinates.Pixels) { GUI.backgroundColor = green; // 渲染编辑对象 outer = HUDEditorTools.IntRect("Dimensions", sprite.outer); Vector4 border = new Vector4( sprite.inner.xMin - sprite.outer.xMin, sprite.inner.yMin - sprite.outer.yMin, sprite.outer.xMax - sprite.inner.xMax, sprite.outer.yMax - sprite.inner.yMax); // 渲染编辑对象 GUI.backgroundColor = blue; border = HUDEditorTools.IntPadding("Border", border); GUI.backgroundColor = Color.white; inner.xMin = sprite.outer.xMin + border.x; inner.yMin = sprite.outer.yMin + border.y; inner.xMax = sprite.outer.xMax - border.z; inner.yMax = sprite.outer.yMax - border.w; } else { // Draw the inner and outer rectangle dimensions GUI.backgroundColor = green; outer = EditorGUILayout.RectField("Outer Rect", sprite.outer); GUI.backgroundColor = blue; inner = EditorGUILayout.RectField("Inner Rect", sprite.inner); GUI.backgroundColor = Color.white; } if (outer.xMax < outer.xMin) { outer.xMax = outer.xMin; } if (outer.yMax < outer.yMin) { outer.yMax = outer.yMin; } if (outer != sprite.outer) { float x = outer.xMin - sprite.outer.xMin; float y = outer.yMin - sprite.outer.yMin; inner.x += x; inner.y += y; } // Sanity checks to ensure that the inner rect is always inside the outer inner.xMin = Mathf.Clamp(inner.xMin, outer.xMin, outer.xMax); inner.xMax = Mathf.Clamp(inner.xMax, outer.xMin, outer.xMax); inner.yMin = Mathf.Clamp(inner.yMin, outer.yMin, outer.yMax); inner.yMax = Mathf.Clamp(inner.yMax, outer.yMin, outer.yMax); bool changed = false; if (sprite.inner != inner || sprite.outer != outer) { sprite.inner = inner; sprite.outer = outer; MarkSpriteAsDirty(); // 应用修改 changed = true; m_bDirty = true; } EditorGUILayout.Separator(); if (atlas.coordinates == UITexAtlas.Coordinates.Pixels) { int left = Mathf.RoundToInt(sprite.paddingLeft * sprite.outer.width); int right = Mathf.RoundToInt(sprite.paddingRight * sprite.outer.width); int top = Mathf.RoundToInt(sprite.paddingTop * sprite.outer.height); int bottom = Mathf.RoundToInt(sprite.paddingBottom * sprite.outer.height); HUDEditorTools.IntVector a = HUDEditorTools.IntPair("Padding", "Left", "Top", left, top); HUDEditorTools.IntVector b = HUDEditorTools.IntPair(null, "Right", "Bottom", right, bottom); if (changed || a.x != left || a.y != top || b.x != right || b.y != bottom) { sprite.paddingLeft = a.x / sprite.outer.width; sprite.paddingTop = a.y / sprite.outer.height; sprite.paddingRight = b.x / sprite.outer.width; sprite.paddingBottom = b.y / sprite.outer.height; MarkSpriteAsDirty(); // 应用修改 m_bDirty = true; changed = true; } } else { // Create a button that can make the coordinates pixel-perfect on click GUILayout.BeginHorizontal(); { GUILayout.Label("Correction", GUILayout.Width(75f)); Rect corrected0 = outer; Rect corrected1 = inner; if (atlas.coordinates == UITexAtlas.Coordinates.Pixels) { corrected0 = HUDMath.MakePixelPerfect(corrected0); corrected1 = HUDMath.MakePixelPerfect(corrected1); } else { corrected0 = HUDMath.MakePixelPerfect(corrected0, atlas.texWidth, atlas.texHeight); corrected1 = HUDMath.MakePixelPerfect(corrected1, atlas.texWidth, atlas.texHeight); } if (corrected0 == sprite.outer && corrected1 == sprite.inner) { GUI.color = Color.grey; GUILayout.Button("Make Pixel-Perfect"); GUI.color = Color.white; } else if (GUILayout.Button("Make Pixel-Perfect")) { outer = corrected0; inner = corrected1; GUI.changed = true; m_bDirty = true; changed = true; } } GUILayout.EndHorizontal(); } if (changed) { m_bDirty = IsChangeSprite(m_sprite, sprite); } HUDEditorTools.DrawSeparator(); GUILayout.BeginHorizontal(); GUI.backgroundColor = m_bDirty ? Color.green : Color.white; if (GUILayout.Button("修改")) { if (m_bDirty && m_sprite != null) { m_sprite.Copy(sprite); MarkSpriteAsDirty(); // 应用修改 AtlasMng_Editor.instance.SaveAltasCfg(); m_bDirty = false; } } if (GUILayout.Button("撤消")) { sprite.Copy(m_sprite); MarkSpriteAsDirty(); // 应用修改 m_bDirty = false; } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); if (HUDEditorTools.previousSelection != null) { //NGUIEditorTools.DrawSeparator(); //GUI.backgroundColor = Color.green; //if (GUILayout.Button("<< Return to " + NGUIEditorTools.previousSelection.name)) //{ // NGUIEditorTools.SelectPrevious(); //} //GUI.backgroundColor = Color.white; } }
protected void SlicedFill(int nSpriteID, int nWidth, int nHeight, int nStart, float fBloodPos) { UISpriteInfo sp = CAtlasMng.instance.GetSafeSpriteByID(nSpriteID); if (sp == null) { return; } if (fBloodPos < 0.0) { fBloodPos = 0.0f; } if (fBloodPos > 1.0f) { fBloodPos = 1.0f; } int nBloodWidth = (int)(nWidth * fBloodPos + 0.5f); int nAtlasID = sp.m_nAtlasID; Rect mOuterUV = sp.outer; Rect mInnerUV = sp.inner; int nOuterW = (int)(mOuterUV.width + 0.5f); int nOuterH = (int)(mOuterUV.height + 0.5f); //int nInnerW = (int)(mInnerUV.width + 0.5f); //int nInnerH = (int)(mInnerUV.height + 0.5f); int nW1 = (int)(mInnerUV.xMin - mOuterUV.xMin + 0.5f); int nH1 = (int)(mInnerUV.yMin - mOuterUV.yMin + 0.5f); int nW2 = (int)(mOuterUV.xMax - mInnerUV.xMax + 0.5f); int nH2 = (int)(mOuterUV.yMax - mInnerUV.yMax + 0.5f); UITexAtlas texAtlas = CAtlasMng.instance.GetAtlasByID(sp.m_nAtlasID); if (texAtlas != null && texAtlas.coordinates == UITexAtlas.Coordinates.Pixels) { mOuterUV = HUDVertex.ConvertToTexCoords(mOuterUV, texAtlas.texWidth, texAtlas.texHeight); mInnerUV = HUDVertex.ConvertToTexCoords(mInnerUV, texAtlas.texWidth, texAtlas.texHeight); } if (nOuterW > 0 && nW1 + nW2 > nBloodWidth) { nW1 = nBloodWidth * nW1 / nOuterW; nW2 = nBloodWidth - nW1; } if (nOuterH > 0 && nH1 + nH2 > nHeight) { nH1 = nHeight * nH1 / nOuterH; nH2 = nHeight - nH1; } //if (nOuterW > 0) //{ // nW1 = nW1 * nBloodWidth / nOuterW; // nW2 = nW2 * nBloodWidth / nOuterW; //} //if (nOuterH > 0) //{ // nH1 = nH1 * nHeight / nOuterH; // nH2 = nH2 * nHeight / nOuterH; //} int nMW = nBloodWidth - nW1 - nW2; int nMH = nHeight - nH1 - nH2; HUDVertex v0 = m_aSprite[nStart]; HUDVertex v1 = m_aSprite[nStart + 1]; HUDVertex v2 = m_aSprite[nStart + 2]; HUDVertex v3 = m_aSprite[nStart + 3]; HUDVertex v4 = m_aSprite[nStart + 4]; HUDVertex v5 = m_aSprite[nStart + 5]; HUDVertex v6 = m_aSprite[nStart + 6]; HUDVertex v7 = m_aSprite[nStart + 7]; HUDVertex v8 = m_aSprite[nStart + 8]; // (mOuterUV.xMin, mOuterUV.yMin) // // (mInnerUV.xMin, mInnerUV.yMin) // (mInnerUV.yMin, mInnerUV.yMax) // // (mOuterUV.xMax, mOuterUV.yMax) // a6 a7 a8 a0 a1 a2 // a3 a4 a5 ==> a3 a4 a5 // a0 a1 a2 a6 a7 a8 float fIn_xMin = mInnerUV.xMin; float fIn_xMax = mInnerUV.xMax; float fIn_yMin = mInnerUV.yMin; float fIn_yMax = mInnerUV.yMax; float fOu_xMin = mOuterUV.xMin; float fOu_xMax = mOuterUV.xMax; float fOu_yMin = mOuterUV.yMin; float fOu_yMax = mOuterUV.yMax; float fX2 = nW1 + nMW; float fY2 = nH2 + nMH; v0.SlicedFill(nW1, nH2, 0f, 0f, fOu_xMin, fOu_yMin, fIn_xMin, fIn_yMin); v1.SlicedFill(nMW, nH2, nW1, 0f, fIn_xMin, fOu_yMin, fIn_xMax, fIn_yMin); v2.SlicedFill(nW2, nH2, fX2, 0f, fIn_xMax, fOu_yMin, fOu_xMax, fIn_yMin); v3.SlicedFill(nW1, nMH, 0f, nH2, fOu_xMin, fIn_yMin, fIn_xMin, fIn_yMax); v4.SlicedFill(nMW, nMH, nW1, nH2, fIn_xMin, fIn_yMin, fIn_xMax, fIn_yMax); v5.SlicedFill(nW2, nMH, fX2, nH2, fIn_xMax, fIn_yMin, fOu_xMax, fIn_yMax); v6.SlicedFill(nW1, nH1, 0f, fY2, fOu_xMin, fIn_yMax, fIn_xMin, fOu_yMax); v7.SlicedFill(nMW, nH1, nW1, fY2, fIn_xMin, fIn_yMax, fIn_xMax, fOu_yMax); v8.SlicedFill(nW2, nH1, fX2, fY2, fIn_xMax, fIn_yMax, fOu_xMax, fOu_yMax); v0.Scale = m_fScale; v1.Scale = m_fScale; v2.Scale = m_fScale; v3.Scale = m_fScale; v4.Scale = m_fScale; v5.Scale = m_fScale; v6.Scale = m_fScale; v7.Scale = m_fScale; v8.Scale = m_fScale; }