Skip to content

Instantly share code, notes, and snippets.

@EsProgram
Created December 5, 2017 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EsProgram/aaabcbc1e6480302db3d253e21e24841 to your computer and use it in GitHub Desktop.
Save EsProgram/aaabcbc1e6480302db3d253e21e24841 to your computer and use it in GitHub Desktop.
Sample replacing RenderTexture with InkPainter.
using System.Linq;
using UnityEngine;
using Es.InkPainter;
public class ReplaceRenderTextureSample : MonoBehaviour
{
[SerializeField]
InkCanvas canvas;
[SerializeField]
Texture replaceTarget;
RenderTexture texture;
private void OnGUI()
{
if(GUILayout.Button("Replace render texture"))
{
//create render texture.
texture = new RenderTexture(replaceTarget.width, replaceTarget.height, 0);
//target convert to render texture.
Graphics.Blit(replaceTarget, texture);
//set render texture.
var paintData = canvas.PaintDatas.FirstOrDefault();
paintData.mainTexture = replaceTarget;
paintData.paintMainTexture = texture;
paintData.material.SetTexture(paintData.mainTexturePropertyID, texture);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment