1
PlayMaker Bug Reporting / Re: Editor crash in 2018.3.2
« on: June 07, 2019, 11:49:22 AM »
We're seeing these crashes again in Unity 2018.4.1f1, PM 1.9.0.p16.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
using UnityEngine;
public class MyComp : MonoBehaviour {
public MyComp up;
public MyComp down;
public MyComp left;
public MyComp right;
}
using HutongGames.PlayMaker;
public class MyBool : FsmBool {
}
using HutongGames.PlayMakerEditor;
using UnityEditor;
using UnityEngine;
[ObjectPropertyDrawer(typeof(MyBool))]
public class MyBoolEditor : ObjectPropertyDrawer {
public override Object OnGUI(GUIContent label, Object obj, bool isSceneObject, params object[] attributes) {
GUILayout.BeginVertical();
obj = EditorGUILayout.ObjectField(label, obj, typeof(MyBool), isSceneObject);
GUILayout.Label("This is a custom object property drawer!");
GUILayout.EndVertical();
return obj;
}
}
public MyBool someBool;
[ActionCategory(ActionCategory.Animation)]
[Tooltip("Sets the current Time of an Animation, Normalize time means 0 (start) to 1 (end); useful if you don't care about the exact time. Check Every Frame to update the time continuously. This variant provides a boolean for each AnimationEvent in the animation.")]
public class MySetAnimationTime : BaseAnimationAction {
[RequiredField]
[CheckForComponent(typeof(Animation))]
public FsmGameObject animatingObject;
[RequiredField]
[ObjectType(typeof(AnimationClip))]
[Tooltip("The animation clip to check for a tag.")]
public FsmObject animationClip;
public FsmFloat time;
public FsmBool[] myBools;
public bool normalized;
public bool everyFrame;
// for our drop-down stuff
[HideInInspector]
public int clipId;
// ---------------------------------------------------------------------------------------- METHODS
private void SetAnimationTime(GameObject go) {
// same code as in SetAnimationTime
}
// ---------------------------------------------------------------------------------------- FSM METHODS
public override void Reset() {
animatingObject = null;
animationClip = null;
time = null;
normalized = false;
everyFrame = false;
initialised = false;
myBools= new FsmBool[0];
return;
}
public override void OnEnter() {
if(initialised) {
// noop
} else {
Init();
}
SetAnimationTime(animatingObject.Value);
if (!everyFrame) {
Finish();
}
return;
}
public override void OnUpdate() {
SetAnimationTime(animatingObject.Value);
return;
}
}
[CustomActionEditor(typeof(MySetAnimationTime))]
public class MySetAnimationTimeEditor : CustomActionEditor {
// -------------------------------------------------------------------------------------------- DATA MEMBERS
// state
GameObject prevObject;
MySetAnimationTime mySetAnimTimeAction;
// -------------------------------------------------------------------------------------------- METHODS
void AnimationClipDropdown() {
// code to choose an AnimationClip from the available clips on this Animation
}
void ShowMyBooleans() {
var numbools = 0;
// get a list of all the events/tags in the animClip
if(null != mySetAnimTimeAction.animationClip && null != ((AnimationClip)mySetAnimTimeAction.animationClip.Value).events) {
var animClip = (AnimationClip)mySetAnimTimeAction.animationClip.Value;
numbools = animClip.events.Length;
// create the array of booleans on the target
if (0 < numbools && (null == mySetAnimTimeAction.myBools || 0 == mySetAnimTimeAction.myBools.Length)) {
mySetAnimTimeAction.myBools = new HutongGames.PlayMaker.FsmBool[numbools];
for (int i=0; i < numbools; ++i) {
mySetAnimTimeAction.myBools[i] = new HutongGames.PlayMaker.FsmBool();
}
}
}
// the label for all the snapping-point bools we're going to select from
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("My Bools");
EditorGUILayout.EndHorizontal();
// show each of the FsmBools
++EditorGUI.indentLevel;
for(int i=0; i < numbools; ++i) {
EditorGUILayout.BeginHorizontal();
if (null == mySetAnimTimeAction.Fsm) {
Debug.LogWarning("no fsm");
} else if (null == mySetAnimTimeAction.myBools[i]) {
Debug.LogWarning("bad eleement " + i);
} else {
mySetAnimTimeAction.myBools[i] =
HutongGames.PlayMakerEditor.VariableEditor.FsmBoolField(new GUIContent("Event " + i), mySetAnimTimeAction.Fsm, mySetAnimTimeAction.myBools[i]);
}
EditorGUILayout.EndHorizontal();
}
--EditorGUI.indentLevel;
return;
}
// -------------------------------------------------------------------------------------------- GUI METHODS
public override bool OnGUI() {
mySetAnimTimeAction = (MySetAnimationTime)target;
EditField("animatingObject");
AnimationClipDropdown();
EditField("time");
EditField("snappedThreshold");
ShowMyBooleans();
EditField("normalized");
EditField("everyFrame");
return GUI.changed;
}
}
public override bool OnGUI() {
...
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Bools");
EditorGUILayout.EndHorizontal();
// show an FsmBool for each required bool
++EditorGUI.indentLevel;
for(int i=0; i < numbools; ++i) {
EditorGUILayout.BeginHorizontal();
if (null == baseAction.Fsm) {
Debug.LogWarning("no fsm");
} else if (null == baseAction.bools[i]) {
Debug.LogWarning("bad element " + i);
} else {
baseAction.bools[i] =
HutongGames.PlayMakerEditor.VariableEditor.FsmBoolField(new GUIContent("Bool " + i), baseAction.Fsm, baseAction.bools[i]);
}
EditorGUILayout.EndHorizontal();
}
--EditorGUI.indentLevel;
...
}