playMaker

Author Topic: FsmObject Variable  (Read 359 times)

Phuzz

  • Junior Playmaker
  • **
  • Posts: 95
    • View Profile
    • Bzilla Games
FsmObject Variable
« on: February 10, 2016, 01:48:34 PM »
Hello,

I am working on a small set of custom actions regarding tk2DTilemaps, I am not a coder and most I do is Copy, Paste, Combine, and ask for help :) Thank you

I have written this code and so far it is working just as expected, the only problem, since the Object required is a tk2dtilemap Object, I cannot have it as a drop down menu so I can choose from a stored Object variable. Only drag and drop works. How can I convert the tk2dtilemap object to be in the Object Variable?

I hope im clear enough, Thank you

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{

[ActionCategory("2D Toolkit/TileMaps")]
[Tooltip("Gets the Tile ID (Sprite ID) at a given position (Vector3) of the Tilemap")]
public class GetTileIDatPosition : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("The Tilemap to Choose from")]
[CheckForComponent(typeof(tk2dTileMap))]

public tk2dTileMap TileObject;

[RequiredField]
[Tooltip("The Layer Number for the target Tile")]
public FsmInt LayerNumber;

[RequiredField]
[Tooltip("The Position for the target Tile")]
public FsmVector3 TilePosition;

[UIHint(UIHint.Variable)]
[Tooltip("Returned Tiled ID")]
public FsmInt TileID;

public override void Reset()
{
TileObject = null;
LayerNumber = null;
TilePosition = null;
}



// Code that runs on entering the state.
public override void OnEnter()
{

DoGetTileID();

{
Finish();
}
}

public override void OnUpdate ()
{
DoGetTileID ();

}

void DoGetTileID()
{

if (TileObject == null)

{
LogWarning("Missing tk2Dtilemap component");
return;

}

{
TileID.Value = TileObject.GetTileIdAtPosition (TilePosition.Value, LayerNumber.Value);

}
}


}

}
Bzilla Games "Education with a Tickle!"
Qbucket Games "Voxel Games"