mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-26 14:00:17 +00:00
add inspector for PedAI
This commit is contained in:
parent
1aabcd2f12
commit
a070f94c21
2 changed files with 77 additions and 0 deletions
66
Assets/Scripts/Editor/PedAIInspector.cs
Normal file
66
Assets/Scripts/Editor/PedAIInspector.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
using System.Linq;
|
||||
using SanAndreasUnity.Behaviours;
|
||||
using SanAndreasUnity.Importing.Paths;
|
||||
using SanAndreasUnity.Utilities;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SanAndreasUnity.Editor
|
||||
{
|
||||
[CustomEditor(typeof(PedAI))]
|
||||
public class PedAIInspector : UnityEditor.Editor
|
||||
{
|
||||
private static bool _foldoutCurrent = true;
|
||||
private static bool _foldoutTarget = true;
|
||||
private static bool _foldoutAdjacentCurrent = true;
|
||||
private static bool _foldoutAdjacentTarget = true;
|
||||
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.DrawDefaultInspector ();
|
||||
|
||||
var pedAI = (PedAI) this.target;
|
||||
|
||||
GUILayout.Space (10);
|
||||
|
||||
DrawForNode(pedAI.CurrentNode, "Current node:", ref _foldoutCurrent, true, ref _foldoutAdjacentCurrent);
|
||||
DrawForNode(pedAI.TargetNode, "Target node:", ref _foldoutTarget, true, ref _foldoutAdjacentTarget);
|
||||
}
|
||||
|
||||
void DrawForNode(PathNode node, string labelText, ref bool foldout, bool showAdjacentNodes, ref bool foldoutAdjacent)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(labelText))
|
||||
foldout = EditorGUILayout.Foldout(foldout, labelText, true);
|
||||
|
||||
if (!foldout)
|
||||
return;
|
||||
|
||||
if (GUILayout.Button("Goto"))
|
||||
GoTo(node);
|
||||
|
||||
EditorUtils.DrawFieldsAndPropertiesInInspector(node, 0);
|
||||
|
||||
if (showAdjacentNodes)
|
||||
{
|
||||
foldoutAdjacent = EditorGUILayout.Foldout(foldoutAdjacent, "Adjacent nodes:", true);
|
||||
if (foldoutAdjacent)
|
||||
{
|
||||
foreach (var adjacentNode in NodeReader.GetAllAdjacentNodes(node))
|
||||
{
|
||||
bool f = true;
|
||||
bool fAdjacent = false;
|
||||
DrawForNode(adjacentNode, "", ref f, false, ref fAdjacent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(5);
|
||||
}
|
||||
|
||||
void GoTo(PathNode node)
|
||||
{
|
||||
SceneView.sceneViews.Cast<SceneView>().ForEach(s => s.LookAt(node.Position));
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Editor/PedAIInspector.cs.meta
Normal file
11
Assets/Scripts/Editor/PedAIInspector.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 799fb27c4637b9040a3d33b7b84b9bdd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in a new issue