中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

陜西省建筑信息平臺(tái)上海搜索引擎優(yōu)化seo

陜西省建筑信息平臺(tái),上海搜索引擎優(yōu)化seo,建設(shè)網(wǎng)站南沙區(qū),wordpress獲取page id原因 想要在編輯器擴(kuò)展也能訪問FairyGUI圖集里面的小圖,隨便找了一下沒有找到接口自己做一個(gè) 方法 使用UIPackage.GetItemByURL獲得小圖信息。從圖集中復(fù)制出小圖,如果有旋轉(zhuǎn)就逆旋轉(zhuǎn)90度即可 圖集里面的小圖是有可能旋轉(zhuǎn)的,可以通過訪問 …

原因

想要在編輯器擴(kuò)展也能訪問FairyGUI圖集里面的小圖,隨便找了一下沒有找到接口自己做一個(gè)

方法

使用UIPackage.GetItemByURL獲得小圖信息。從圖集中復(fù)制出小圖,如果有旋轉(zhuǎn)就逆旋轉(zhuǎn)90度即可
圖集里面的小圖是有可能旋轉(zhuǎn)的,可以通過訪問 NTexture.rotated 判斷在圖集中是否旋轉(zhuǎn)

獲取小圖在圖集中的起始位置

X偏移坐標(biāo)可以直接 uvRect.min.x * nativeTexture.width 得到真實(shí)的X偏移
Y坐標(biāo)可以根據(jù)uvRect賦值反過來(lái)獲得,原有公式是

uvRect.min.y = 1 - region.yMax / _nativeTexture.height

那么真實(shí)的公式就是

y = (1 - startOffset.y) * nativeTexture.height - textureSize.y

無(wú)非就是交互律。還原public NTexture(Texture texture, Rect region) 構(gòu)造傳入來(lái)的region參數(shù)

獲得偏移和大小后只需要使用RenderTexture把小圖讀出來(lái)就好

        RenderTexture renderTex = RenderTexture.GetTemporary(nativeTexture.width, nativeTexture.height, 24, RenderTextureFormat.Default, RenderTextureReadWrite.Linear);Graphics.Blit(nativeTexture, renderTex);RenderTexture previous = RenderTexture.active;RenderTexture.active = renderTex;Texture2D resultTexture = new Texture2D(textureSize.x, textureSize.y, nativeTexture.format, false);resultTexture.ReadPixels(new Rect((int)startOffset.x, (int)startOffset.y, textureSize.x, textureSize.y), 0, 0);resultTexture.Apply();RenderTexture.active = previous;RenderTexture.ReleaseTemporary(renderTex);

圖集中的小圖是會(huì)旋轉(zhuǎn)的應(yīng)該如何還原

Texture2D.GetPixel 和 Texture2D.SetPixel 接口讀寫非常慢
可以直接使用GetPixelData或者GetPixels導(dǎo)出圖像數(shù)據(jù)數(shù)組,操作完成后刷新圖像數(shù)據(jù)
根據(jù) nativeTexture.format 類型使用Color或者Color32格式讀取

var colorArray = resultTexture.GetPixelData<Color32>(0)

有數(shù)組后簡(jiǎn)單逆旋轉(zhuǎn)90數(shù)組數(shù)據(jù),就可以得到原來(lái)的小圖

for (int i = 0; i < textureSize.x; i++)
{for (int j = 0; j < textureSize.y; j++){colors[i * textureSize.y + j] = colorArray[textureSize.x - 1 - i + j * textureSize.x];}
}

完整代碼

    public Texture GetTexture(string url){PackageItem packageItem = UIPackage.GetItemByURL(url);if (packageItem == null)return null;NTexture nTexture = packageItem.texture;Texture2D nativeTexture = nTexture.nativeTexture as Texture2D;var startOffset = nTexture.uvRect.min;var textureSize = new Vector2Int(nTexture.width, nTexture.height);if (nTexture.rotated)textureSize = new Vector2Int(nTexture.height, nTexture.width);startOffset.x *= nativeTexture.width;startOffset.y = (1 - startOffset.y) * nativeTexture.height - textureSize.y;RenderTexture renderTex = RenderTexture.GetTemporary(nativeTexture.width, nativeTexture.height, 24, RenderTextureFormat.Default, RenderTextureReadWrite.Linear);Graphics.Blit(nativeTexture, renderTex);RenderTexture previous = RenderTexture.active;RenderTexture.active = renderTex;Texture2D resultTexture = new Texture2D(textureSize.x, textureSize.y, nativeTexture.format, false);resultTexture.ReadPixels(new Rect((int)startOffset.x, (int)startOffset.y, textureSize.x, textureSize.y), 0, 0);resultTexture.Apply();RenderTexture.active = previous;RenderTexture.ReleaseTemporary(renderTex);if (nTexture.rotated){var colorArray = resultTexture.GetPixelData<Color32>(0);Texture2D rotationTexture = new Texture2D(textureSize.y, textureSize.x, nativeTexture.format, false);var colors = rotationTexture.GetPixelData<Color32>(0);for (int i = 0; i < textureSize.x; i++){for (int j = 0; j < textureSize.y; j++){colors[i * textureSize.y + j] = colorArray[textureSize.x - 1 - i + j * textureSize.x];}}rotationTexture.SetPixelData(colors, 0);rotationTexture.Apply();Object.Destroy(resultTexture);resultTexture = rotationTexture;}return resultTexture;}
http://www.risenshineclean.com/news/1943.html

相關(guān)文章:

  • 開封網(wǎng)站建設(shè)怎么做一個(gè)網(wǎng)站平臺(tái)
  • 哪些網(wǎng)站是用wordpressseo網(wǎng)站優(yōu)化詳解
  • 成都 網(wǎng)站百度平臺(tái)商戶電話號(hào)碼
  • 模板網(wǎng)站劣勢(shì)seo整合營(yíng)銷
  • 鶴山網(wǎng)站建設(shè)易搜互聯(lián)品牌推廣內(nèi)容
  • 做網(wǎng)站設(shè)計(jì)參考文獻(xiàn)seo兼職論壇
  • 煙臺(tái)有沒有做網(wǎng)站十大軟件免費(fèi)下載網(wǎng)站排行榜
  • 湘潭哪里做網(wǎng)站排名前十的大學(xué)
  • www.網(wǎng)站建設(shè)google引擎免費(fèi)入口
  • 做彩妝網(wǎng)站的公司成都高新seo
  • 怎么篩選一家做網(wǎng)站做的好的公司西安網(wǎng)站seo
  • 免費(fèi)推廣網(wǎng)站方法大集合網(wǎng)站怎么優(yōu)化自己免費(fèi)
  • 制作精美網(wǎng)站建設(shè)售后完善公司網(wǎng)站建設(shè)服務(wù)機(jī)構(gòu)
  • 深圳企業(yè)網(wǎng)站推廣關(guān)鍵詞優(yōu)化一般收費(fèi)價(jià)格
  • 做電影網(wǎng)站用什么軟件有哪些seo教程seo優(yōu)化
  • 做字幕模板下載網(wǎng)站有哪些英文谷歌優(yōu)化
  • 做笑話網(wǎng)站賺錢站長(zhǎng)統(tǒng)計(jì)app進(jìn)入網(wǎng)址新版小豬
  • 網(wǎng)站建設(shè)有免費(fèi)的空間嗎網(wǎng)絡(luò)優(yōu)化的內(nèi)容包括哪些
  • 互聯(lián)網(wǎng)推廣加盟搜索引擎優(yōu)化工具
  • 福州營(yíng)銷網(wǎng)站建設(shè)模板如何制作網(wǎng)站和網(wǎng)頁(yè)
  • 網(wǎng)站開發(fā)語(yǔ)言入門瀏覽器直接進(jìn)入網(wǎng)站的注意事項(xiàng)
  • 嘉興秀洲區(qū)全網(wǎng)seo優(yōu)化優(yōu)惠廈門seo關(guān)鍵詞
  • 聯(lián)系昆明網(wǎng)站建設(shè)推廣app用什么平臺(tái)比較好
  • wordpress菜單外觀樣式seo推廣優(yōu)化排名軟件
  • 開發(fā)網(wǎng)站要注意什么問題推廣計(jì)劃書范文
  • 做數(shù)學(xué)的網(wǎng)站視頻外鏈平臺(tái)
  • 建個(gè)網(wǎng)站的電話廣東seo網(wǎng)絡(luò)培訓(xùn)
  • java eclipse做網(wǎng)站網(wǎng)頁(yè)制作在線生成
  • 如果是創(chuàng)建的網(wǎng)站網(wǎng)站快速排名優(yōu)化價(jià)格
  • 百度做網(wǎng)站找誰(shuí)智能建站系統(tǒng)