I have made some textures for my compass, one for the actual compass and one frame for it with a transparent
bow/hole in the middle so you only see the current direction N W S E.
However, my problem is that the NWSE textures covers the the frame and not vice versa, the frame should cover the compass.
Is there a way to determine what texture should be on top and on the background?
using UnityEngine;
using System.Collections;
public class CompassFrame : MonoBehaviour {
public Texture bTexture;
public Texture aTexture;
void OnGUI() {
if (Event.current.type.Equals(EventType.Repaint))
Graphics.DrawTexture(new Rect(0, 740, 485, 150), bTexture);
Graphics.DrawTexture(new Rect(794, 0, 330, 50), aTexture);
}
}
EDIT: the texture B dont go for the compass, thats a box for the chat, i putted it there just to collect texturedrawings in same script, the texturedrawing for the compass is in the actual compass script, but i still want the aTexture to on top no matter other texture there is on the screen
Your if statement is only affecting the following line, since you’re not using braces. But you should use GUI.DrawTexture in OnGUI anyway (and get rid of the if statement). Within the same OnGUI function, stuff is drawn in the order that the code runs, so later things will be drawn on top of earlier things.