【texture】封装texture的创建

main
马远征 2025-07-02 12:42:25 +08:00
parent e24473c54b
commit ed39b5fb4d
4 changed files with 3 additions and 5 deletions

View File

@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
@ -50,7 +48,7 @@ public class SplitTextureUtil
var realHeight = r == row - 1 ? rowReminder : height;
var pixelCount = realWidth * realHeight;
var textureOutput = new Texture2D(realWidth, realHeight);
var textureOutput = PhxhSDK.Utils.CreateTexture($"split_{texture.name}_{r}_{c}", realWidth, realHeight);
Color[] pixels = new Color[pixelCount];
var startIndex = r * height * texture.width + c * width;
for (int i = 0; i < pixelCount; i++)

View File

@ -194,7 +194,7 @@ public static class TwoDimensionRenderUtil
var twoDimensionPositionWS = TwoDimensionToWorldPosition(camera);
positionOffset = twoDimensionPositionWS - meshTrans.position;
RenderTexture.active = _currRT;
Texture2D tex = new Texture2D(rtWidth, rtHeight);
Texture2D tex = PhxhSDK.Utils.CreateTexture(gameObject.name, rtWidth, rtHeight);
tex.ReadPixels(new Rect(0, 0, rtWidth, rtHeight), 0, 0);
tex.Apply();
Byte[] bytes = tex.EncodeToJPG();

@ -1 +1 @@
Subproject commit 99b40c06af0fe325fa15c896f6325cb11eaf2610
Subproject commit 6623ea90bc51b00a3ed4d3de16b436a7d9ee6c97