-
Notifications
You must be signed in to change notification settings - Fork 3
/
GetBoxColliderSize.cs
79 lines (57 loc) · 2.06 KB
/
GetBoxColliderSize.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// License: Attribution 4.0 International (CC BY 4.0)
/*--- __ECO__ __PLAYMAKER__ __ACTION__ ---*/
// Keywords: Set the size of boxCollider
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Physics)]
[Tooltip("Set the size of a Box Collider")]
[HelpUrl("http://hutonggames.com/playmakerforum/index.php?topic=12040.0")]
public class GetBoxColliderSize : ComponentAction<Rigidbody>
{
[RequiredField]
[CheckForComponent(typeof(BoxCollider))]
[Tooltip("The GameObject to apply the size to.")]
public FsmOwnerDefault gameObject;
public FsmVector3 size;
[Tooltip("size along the X axis. To leave unchanged, set to 'None'.")]
public FsmFloat x;
[Tooltip("size along the Y axis. To leave unchanged, set to 'None'.")]
public FsmFloat y;
[Tooltip("size along the Z axis. To leave unchanged, set to 'None'.")]
public FsmFloat z;
[Tooltip("Repeat every frame while the state is active.")]
public FsmBool everyFrame;
public override void Reset()
{
gameObject = null;
x = new FsmFloat { UseVariable = true };
y = new FsmFloat { UseVariable = true };
z = new FsmFloat { UseVariable = true };
everyFrame = false;
}
public override void OnEnter()
{
DoChange();
if (!everyFrame.Value)
{
Finish();
}
}
public override void OnFixedUpdate()
{
DoChange();
}
void DoChange()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
BoxCollider collider = go.GetComponent<BoxCollider>();
//Debug.Log(collider);
//Debug.Log(collider.size);
size.Value = collider.size;
x.Value = collider.size.x;
y.Value = collider.size.y;
z.Value = collider.size.z;
}
}
}