How to draw custom task references in custom editor script?

YnS

New member
I tried to implement my custom editor script with a reference to another task I created. But I do not know how to draw these tasks correctly. I tried to use
MonoScript.FromMonoBehaviour to get the class value but it was not working.

Here is my code and EnemyMove is my custom action task. If I want to draw the editor just like normal(with a select button and task name under), what method should I use to achieve that

C#:
public EnemyJump jumpToStartPoint;  //EnemyJump is a action task

//Here is my code trying to implement the draw call
customClass.jumpToStartPoint = EditorGUILayout.ObjectField("Script Name: ", MonoScript.FromMonoBehaviour((EnemyJump)customClass.jumpToStartPoint), typeof(EnemyJump), true) as EnemyJump;

111.png
 
What are you trying to draw? The fields from a referenced task? For that you will need to use reflection to loop through the task fields
 
What are you trying to draw? The fields from a referenced task? For that you will need to use reflection to loop through the task fields
I am trying to draw the reference of my custom task just like the image shows (with a button to select task and information under) .The image is showing the result without using the custom editor.
 
Ah, that part isn't as easy to do through a custom inspector. You are actually the first person that I've had request this. I'll see if I can make it easier in the next update.
 
Ah, that part isn't as easy to do through a custom inspector. You are actually the first person that I've had request this. I'll see if I can make it easier in the next update.
Thanks for the clarification! Is there another way to refer to a task?
 
This isn't as seamless but one way would be to show a list of task names/types and then use BehaviorTree.FindTask at runtime to get the reference to the task. This is also very specific to your task but if you aren't drawing many fields you could have Behavior Designer draw the task fields like normal, and then only use object drawers for the individual field types.
 
This isn't as seamless but one way would be to show a list of task names/types and then use BehaviorTree.FindTask at runtime to get the reference to the task. This is also very specific to your task but if you aren't drawing many fields you could have Behavior Designer draw the task fields like normal, and then only use object drawers for the individual field types.
Got it. But since I have multiple same tasks in my BT(and it is a huge tree right now), I just removed the reference and monitor the required field with a shared boolean. But still thanks for the reply!
 
Top