playMaker

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

giyomu

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 108
    • blog
GetTextureSize ( beta 9 )
« 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;
}
}