Hi, I'm in a terrible struggle with the GUITexture action
. I want it to define its depth too, but for some reason it's not working. I had to use a real int and not an FSMint because the FSMint gave me an error, stating that it couldn't be converted to a normal int. If I knew how to convert it I would have done so though
So in the end all I could do is define the depth int and then use it... I don't understand why it isn't working :S
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.GUI)]
[Tooltip("Draws a GUI Texture. NOTE: Uses OnGUI so you need a PlayMakerGUI component in the scene.")]
public class DrawTexture : FsmStateAction
{
[RequiredField]
public FsmTexture texture;
[UIHint(UIHint.Variable)]
[Tooltip("Rectangle on the screen to draw the texture within. Alternatively, set or override individual properties below.")]
[Title("Position")]
public FsmRect screenRect;
public FsmFloat left;
public FsmFloat top;
public FsmFloat width;
public FsmFloat height;
public int depth;
[Tooltip("How to scale the image when the aspect ratio of it doesn't fit the aspect ratio to be drawn within.")]
public ScaleMode scaleMode;
[Tooltip("Whether to alpha blend the image on to the display (the default). If false, the picture is drawn on to the display.")]
public FsmBool alphaBlend;
[Tooltip("Aspect ratio to use for the source image. If 0 (the default), the aspect ratio from the image is used. Pass in w/h for the desired aspect ratio. This allows the aspect ratio of the source image to be adjusted without changing the pixel width and height.")]
public FsmFloat imageAspect;
[Tooltip("Use normalized screen coordinates (0-1)")]
public FsmBool normalized;
private Rect rect;
public override void Reset()
{
texture = null;
screenRect = null;
left = 0;
top = 0;
width = 1;
height = 1;
scaleMode = ScaleMode.StretchToFill;
alphaBlend = true;
imageAspect = 0;
normalized = true;
depth = 0;
}
public override void OnGUI()
{
if (texture.Value == null)
{
return;
}
rect = !screenRect.IsNone ? screenRect.Value : new Rect();
if (!left.IsNone) rect.x = left.Value;
if (!top.IsNone) rect.y = top.Value;
if (!width.IsNone) rect.width = width.Value;
if (!height.IsNone) rect.height = height.Value;
if (normalized.Value)
{
rect.x *= Screen.width;
rect.width *= Screen.width;
rect.y *= Screen.height;
rect.height *= Screen.height;
}
GUI.depth = depth;
GUI.DrawTexture(rect, texture.Value, scaleMode, alphaBlend.Value, imageAspect.Value);
}
}
}
could anyone spare a short moment for my ignorance?