forked from sin365/AxibugEmuOnline
Compare commits
No commits in common. "959956706f3901ccbccd720e67c62c9e5c31c262" and "49d0a9aa868b5547772dac037215639a3fe47d17" have entirely different histories.
959956706f
...
49d0a9aa86
@ -551,13 +551,13 @@ RectTransform:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 4232056521759880276}
|
m_GameObject: {fileID: 4232056521759880276}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 1, y: 0, z: 0, w: 0}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: -1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 4232056520494431727}
|
m_Father: {fileID: 4232056520494431727}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 180, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 1, y: 1}
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
|
|||||||
@ -1688,7 +1688,7 @@ RectTransform:
|
|||||||
m_GameObject: {fileID: 5162569472849600096}
|
m_GameObject: {fileID: 5162569472849600096}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: -1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 5970282275929291192}
|
m_Father: {fileID: 5970282275929291192}
|
||||||
|
|||||||
@ -67,7 +67,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
var stateData = m_ingameUI.Core.GetStateBytes();
|
var stateData = m_ingameUI.Core.GetStateBytes();
|
||||||
var tex = m_ingameUI.Core.OutputPixel;
|
var tex = m_ingameUI.Core.OutputPixel;
|
||||||
var screenData = tex.ToJPG(m_ingameUI.Core.DrawCanvas.transform.localScale);
|
var screenData = tex.ToJPG();
|
||||||
|
|
||||||
m_savFile.Save(m_savFile.Sequecen, stateData, screenData);
|
m_savFile.Save(m_savFile.Sequecen, stateData, screenData);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,26 +55,29 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] ToJPG(this Texture texture, Vector2 scale)
|
public static byte[] ToJPG(this Texture texture)
|
||||||
{
|
{
|
||||||
Texture2D outputTex = ConvertFromRenderTexture(texture, scale);
|
Texture2D outputTex = null;
|
||||||
|
if (texture is RenderTexture rt)
|
||||||
|
{
|
||||||
|
outputTex = ConvertFromRenderTexture(rt);
|
||||||
|
}
|
||||||
|
else if (texture is Texture2D)
|
||||||
|
{
|
||||||
|
outputTex = texture as Texture2D;
|
||||||
|
}
|
||||||
|
|
||||||
return outputTex.EncodeToJPG();
|
return outputTex.EncodeToJPG();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Texture2D ConvertFromRenderTexture(Texture src, Vector2 scale)
|
private static Texture2D ConvertFromRenderTexture(RenderTexture rt)
|
||||||
{
|
{
|
||||||
float offsetX = (scale.x < 0) ? 1 : 0;
|
|
||||||
float offsetY = (scale.y < 0) ? 1 : 0;
|
|
||||||
|
|
||||||
var offset = new Vector2(offsetX, offsetY);
|
|
||||||
|
|
||||||
// 创建临时RenderTexture并拷贝内容
|
// 创建临时RenderTexture并拷贝内容
|
||||||
RenderTexture tempRT = RenderTexture.GetTemporary(src.width, src.height, 0, RenderTextureFormat.ARGB32);
|
RenderTexture tempRT = RenderTexture.GetTemporary(rt.width, rt.height, 0, RenderTextureFormat.ARGB32);
|
||||||
Graphics.Blit(src, tempRT, scale, offset);
|
Graphics.Blit(rt, tempRT);
|
||||||
|
|
||||||
// 读取到Texture2D
|
// 读取到Texture2D
|
||||||
Texture2D tex = new Texture2D(src.width, src.height, TextureFormat.RGBA32, false);
|
Texture2D tex = new Texture2D(rt.width, rt.height, TextureFormat.RGBA32, false);
|
||||||
RenderTexture.active = tempRT;
|
RenderTexture.active = tempRT;
|
||||||
tex.ReadPixels(new Rect(0, 0, tempRT.width, tempRT.height), 0, 0);
|
tex.ReadPixels(new Rect(0, 0, tempRT.width, tempRT.height), 0, 0);
|
||||||
tex.Apply();
|
tex.Apply();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user