我使用
Graphics.Blit (null, finalRT, mat);
合成出一張finalRT,然后將finalRT用在editor腳本的OnInspector中使用
Graphics.DrawTexture(rect,finalRT,mat2);
進行繪制,結果發現inspector面板中finalRT顯示結果是錯的,而且在游戲場景中用到finalRT作為紋理的物體紋理也變錯了。
但是如果我屏蔽掉Graphics.DrawTexture(rect,finalRT,mat2),則游戲場景中用finalRT作為紋理的對象不會變錯,但是當然,我在inspector中就看不到finalRT的預覽了。
通過試驗發現,如果在Graphics.Blit (null, finalRT, mat)后面緊跟着加一句:
#if UNITY_EDITOR
Graphics.Blit (null, null, mat,0);//if i want to draw finalRT with a shader in editor script, i must write this line, why?
# endif
則結果就正常了。
不知道為啥。