Playmaker Forum
PlayMaker Feedback => Feature Requests => Topic started by: blackant on December 31, 2018, 02:25:25 PM
-
Hello,
happy new year by the way !!!! ;)
i'm surprised because on the forum there is 0 result on Bounds search...
and i'm writing here because the playmaker actions doesn't containt any way to use them in the editor.
and i was writing a code specially for it:
-
Hi,
can you show the code of the custom action. Bound is supported, I made plenty of actions using bound one way or the other.
check out GetColliderBounds from the Ecosystem for example.
Bye,
Jean
-
There is nothing special in my code, i certainly missed something.
yes i ste it as public, this is why i get the message
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Terrain")]
[Tooltip("Get the local bounding box of the TerrainData object.")]
public class GetTerrainBounds : FsmStateAction
{
public Terrain terrain;
public Bounds bounds;
// Code that runs on entering the state.
public override void OnEnter()
{
bounds = terrain.terrainData.bounds;
Finish();
}
}
}
-
Hi,
yes, Bounds is a struct, you can't use it like that, you need to save it as a private variable and expose its properties individually.
Typically I solved this kind of problem with a public static dictionnary where the key is a custom string acting as a reference that you set in your action ( like arrayMaker or xmlMaker), and then other actions can use bounds by this reference key. This is the best option as far as I can see. Otherwise you need to create serializable class which create garbage collection and it's not that great...
using UnityEngine;
using System.Collections.Generic;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Terrain")]
[Tooltip("Get the local bounding box of the TerrainData object.")]
public class GetTerrainBounds : FsmStateAction
{
// you can then get to a bound using: GetTerrainBounds.BoundsLUT["My Reference"];
public static Dictionary<string, Bounds> BoundsLUT;
public Terrain terrain;
public FsmString BoundReference;
// Code that runs on entering the state.
public override void OnEnter()
{
if (BoundsLUT == null)
{
BoundsLUT = new Dictionary<string, Bounds>();
}
BoundsLUT[BoundReference.Value] = terrain.terrainData.bounds;
Finish();
}
}
}
one last option is to create scriptableObject again as a wrapp of your bound, but again you need to create them carefully and at edit time, so that they don't crate garbage collection and/or memory leak.
Bye,
Jean