浏览代码

[canvas2d] change canvas element to use render textures.

/main
Tim Cooper 9 年前
当前提交
f119ce26
共有 1 个文件被更改,包括 8 次插入11 次删除
  1. 19
      UnityProject/Assets/GraphFramework/Canvas2D/Editor/Canvas2D.cs

19
UnityProject/Assets/GraphFramework/Canvas2D/Editor/Canvas2D.cs


protected Vector3 m_Scale = Vector3.one;
protected bool m_Selected = false;
protected bool m_Collapsed = false;
protected Texture2D m_Texture = null;
protected RenderTexture m_Texture = null;
protected CanvasElement m_Parent = null;
protected Object m_Target = null;
protected bool m_SupportsRenderToTexture = true;

set { m_zIndex = value; }
}
public Texture2D texture
public Texture texture
{
get { return m_Texture; }
}

private void CreateTexture()
{
Rect textureRect = boundingRect;
m_Texture = new Texture2D((int) textureRect.width, (int) textureRect.height, TextureFormat.ARGB32, true)
{
filterMode = FilterMode.Trilinear,
wrapMode = TextureWrapMode.Clamp
};
m_Texture = new RenderTexture((int) textureRect.width, (int) textureRect.height, 0, RenderTextureFormat.ARGB32);
private RenderTexture m_OldActive;
public bool PrepareRender()
{
if (Event.current.type != EventType.Repaint)

CreateTexture();
}
m_OldActive = RenderTexture.active;
RenderTexture.active = m_Texture;
Layout();
m_Dirty = false;
return true;

{
Rect textureRect = boundingRect;
float origin = SystemInfo.graphicsDeviceVersion.StartsWith("Direct") ? 0 : renderTextureHeight - textureRect.height;
m_Texture.ReadPixels(new Rect(0, origin, textureRect.width, textureRect.height), 0, 0);
m_Texture.Apply();
RenderTexture.active = m_OldActive;
}
bool Collide(Vector2 p)

正在加载...
取消
保存