Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: giyomu on July 05, 2011, 02:06:36 AM

Title: GetTextureSize ( beta 9 )
Post by: giyomu on July 05, 2011, 02:06:36 AM
can be useful... for something  ;D

Code: [Select]
using UnityEngine;
using HutongGames.PlayMaker;

[ActionCategory("Texture")]
[Tooltip("Get the size in pixel of a texture")]
public class GetTextureSize : FsmStateAction
{
[RequiredField]
public FsmTexture targetTexture;
public FsmInt storedWidth;
public FsmInt storedHeight;

public override void Reset ()
{
targetTexture = null;
storedWidth = null;
storedHeight = null;
}

public override void OnEnter ()
{
DoGetTextureSize();
Finish();
}

void DoGetTextureSize()
{
if(targetTexture.IsNone)
return;

storedWidth.Value = targetTexture.Value.width;
storedHeight.Value = targetTexture.Value.height;
}
}