Created
December 5, 2017 01:34
-
-
Save EsProgram/aaabcbc1e6480302db3d253e21e24841 to your computer and use it in GitHub Desktop.
Sample replacing RenderTexture with InkPainter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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