playMaker

Author Topic: GetTextureSize ( beta 9 )  (Read 869 times)

giyomu

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 108
    • View Profile
    • blog
GetTextureSize ( beta 9 )
« on: July 04, 2011, 11:06:36 PM »
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;
}
}