概要
Particle, Texture, その他をLayerに分けて、それぞれのLayerを表示するカメラを作る
OnGUIとGUI.DrawTextureを使わずに、OnRenderObjectとGraphics.DrawTextureを使うのがポイント
やること
- Particle, Texture, その他をLayerに分ける
- Textureを表示する際にはOnGUIではなく、OnRenderObjectで
- カメラをParticle, Texture, その他のLayerを映すようにする (depthは Particle > Texture > その他)
ゲームオブジェクト
Particle
Textureの上に表示させるParticle
LayerをParticleにしておく。
Texture
Particleの下にあるTexture
LayerをTextureにしておく。
ポイント
Layerを設定するために、空のゲームオブジェクトを別に作り、そこにTexture生成用のスクリプトを貼り付ける。
OnGUIとGUI.DrawTextureを使わずに、OnRenderObjectとGraphics.DrawTextureを使う!
void OnRenderObject() {
Graphics.DrawTexture(new Rect(x, y, width, height), yourTexture);
}
その他
カメラ
Particle用カメラ
| Clear Flags | Depth only |
| Culling Mask | Particle |
| Depth | 1 |
| AudioListener | チェックを外す |
Texture用カメラ
| Clear Flags | Depth only |
| Culling Mask | Texture |
| Depth | 0 |
| AudioListener | チェックを外す |
その他のカメラ
| Clear Flags | Skybox |
| Culling Mask | Particle、Texture以外 |
| Depth | -1 |
| AudioListener | チェックはつける |
参考





