unity, Graphics.Blit (null, null, mat,0);


我使用

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

則結果就正常了。

不知道為啥。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM