浏览代码

Update pathway config SO to work with the latest pathway editor changes

/main
Yohann Puyhaubert 4 年前
当前提交
6bee54e4
共有 12 个文件被更改,包括 104 次插入45 次删除
  1. 39
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Config/NPCPathwayConfig.asset
  2. 49
      UOP1_Project/Assets/Scripts/Characters/Config/PathwayConfigSO.cs
  3. 4
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/MovementActions/PathwayMovementAction.cs
  4. 4
      UOP1_Project/Assets/Scripts/Editor/Pathway/PathWayNavMeshUI.cs
  5. 17
      UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayEditor.cs
  6. 18
      UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayGizmos.cs
  7. 4
      UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayHandles.cs
  8. 4
      UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayNavMesh.cs
  9. 2
      UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayHandles.cs.meta
  10. 8
      UOP1_Project/Assets/Scripts/Pathway.meta
  11. 0
      /UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayHandles.cs.meta

39
UOP1_Project/Assets/ScriptableObjects/StateMachine/Config/NPCPathwayConfig.asset


m_EditorClassIdentifier:
_stopDuration: 0.5
_speed: 1
waypoints:
- {x: 0, y: 0.033730388, z: 0}
- {x: 0, y: 0.033730388, z: 0}
- {x: 0, y: 0.033730388, z: 0}
- {x: 0, y: 0.033730388, z: 0}
- {x: 0, y: 0.033730388, z: 0}
- {x: 0, y: 0.033730388, z: 0}
- {x: 0, y: 0.033730388, z: 0}
HidePathway: 0
_lineColor: {r: 0, g: 0.19270587, b: 1, a: 1}
_textSize: 20
_textColor: {r: 1, g: 1, b: 1, a: 1}
_probeRadius: 13.2
DisplayProbes: 0
ToggledNavMeshDisplay: 0
RealTimeEnabled: 1
- {x: 3.46387, y: 0.033730388, z: 0.55213976}
- {x: 5.6019807, y: 0.052446984, z: 7.11369}
- {x: -2.8645186, y: 0.033730388, z: 8.923655}
- {x: -6.567141, y: 0.033730388, z: -5.250761}
- {x: -9.866049, y: 0.033730388, z: -5.822654}
- {x: -11.059804, y: 0.033730388, z: -2.8135128}
- {x: -2.0687637, y: 0.033730388, z: 0.8148103}
_pathwayEditorColor: {r: 0, g: 1, b: 1, a: 1}
- waypoint: {x: -8.50028, y: 0.033730388, z: 1.5602589}
corners:
- {x: -8.50028, y: 0.033730388, z: 1.5602589}
- {x: 2.6641674, y: 0.033730388, z: -8.3147135}
- waypoint: {x: 2.6641674, y: 0.033730388, z: -8.3147135}
corners:
- {x: 2.6641674, y: 0.033730388, z: -8.3147135}
- {x: 4, y: 0.033730388, z: -6.799999}
- {x: 10.939352, y: 0.15480933, z: -0.32895184}
- waypoint: {x: 10.939352, y: 0.15480933, z: -0.32895184}
corners:
- {x: 10.939352, y: 0.15480933, z: -0.32895184}
- {x: 5.6, y: 0.033730388, z: -0.8999996}
- {x: 4.8, y: 0.033730388, z: -0.8999996}
- {x: -8.50028, y: 0.033730388, z: 1.5602589}

49
UOP1_Project/Assets/Scripts/Characters/Config/PathwayConfigSO.cs


[CreateAssetMenu(fileName = "PathwayConfig", menuName = "EntityConfig/Pathway Config")]
public class PathwayConfigSO : NPCMovementConfigSO
{
[HideInInspector] public List<Vector3> Waypoints;
[HideInInspector]
public Vector3[] waypoints;
public bool HidePathway;
private Color _pathwayEditorColor = Color.cyan;
private int _textSize = 10;
private Color _lineColor = Color.black;
[SerializeField, Range(0, 100)]
private int _textSize = 20;
[SerializeField]
[SerializeField, Range(0, 100)]
[Tooltip("This function may reduce the frame rate if a large probe radius is specified. To avoid frame rate issues," +
" it is recommended that you specify a max distance of twice the agent height.")]
private float _probeRadius = 3;
[HideInInspector]
public bool DisplayProbes;
[HideInInspector]
public bool ToggledNavMeshDisplay;
private List<Vector3> _path;
private List<bool> _hits;
public Color LineColor { get => _pathwayEditorColor; }
public Color LineColor { get => _lineColor; }
public float ProbeRadius { get => _probeRadius; }
public List<Vector3> Path { get => _path; set => _path = value; }
public List<bool> Hits { get => _hits; set => _hits = value; }
public bool RealTimeEnabled;
[HideInInspector]
public List<WaypointData> Waypoints;
#if UNITY_EDITOR
[System.Serializable]
public class WaypointData
{
public Vector3 waypoint;
public List<Vector3> corners;
}
#endif

4
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/MovementActions/PathwayMovementAction.cs


{
private NavMeshAgent _agent;
private bool _isActiveAgent;
private List<Vector3> _wayppoints;
private List<WaypointData> _wayppoints;
private int _wayPointIndex;
private float _roamingSpeed;

if (_wayppoints.Count > 0)
{
_wayPointIndex = (_wayPointIndex + 1) % _wayppoints.Count;
result = _wayppoints[_wayPointIndex];
result = _wayppoints[_wayPointIndex].waypoint;
}
return result;
}

4
UOP1_Project/Assets/Scripts/Editor/Pathway/PathWayNavMeshUI.cs


public class PathWayNavMeshUI
{
private Pathway _pathway;
private PathwayConfigSO _pathway;
public PathWayNavMeshUI(Pathway pathway)
public PathWayNavMeshUI(PathwayConfigSO pathway)
{
_pathway = pathway;
_pathwayNavMesh = new PathwayNavMesh(pathway);

17
UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayEditor.cs


using UnityEditorInternal;
using System.Linq;
[CustomEditor(typeof(Pathway))]
[CustomEditor(typeof(PathwayConfigSO))]
private Pathway _pathway;
private PathwayConfigSO _pathway;
private PathwayHandles _pathwayHandles;
private PathWayNavMeshUI _pathWayNavMeshUI;
private enum LIST_MODIFICATION { ADD, SUPP, DRAG, OTHER };

public void OnSceneGUI()
public void OnSceneGUI(SceneView sceneView)
PathwayGizmos.DrawGizmosSelected(_pathway, GizmoType.Active);
}
public override void OnInspectorGUI()

_reorderableList.onRemoveCallback += RemoveItem;
_reorderableList.onChangedCallback += ListModified;
_reorderableList.onMouseDragCallback += DragItem;
_pathway = (target as Pathway);
_pathway = (target as PathwayConfigSO);
SceneView.duringSceneGui += this.OnSceneGUI;
}
private void OnDisable()

_reorderableList.onChangedCallback -= ListModified;
_reorderableList.onMouseDragCallback -= DragItem;
_pathway.waypoints = _pathway.Waypoints.Select(x => x.waypoint).ToArray();
SceneView.duringSceneGui -= this.OnSceneGUI;
GUI.Label(rect, Pathway.TITLE_LABEL);
GUI.Label(rect, PathwayConfigSO.TITLE_LABEL);
item.vector3Value = EditorGUI.Vector3Field(rect, Pathway.FIELD_LABEL + index, item.vector3Value);
item.vector3Value = EditorGUI.Vector3Field(rect, PathwayConfigSO.FIELD_LABEL + index, item.vector3Value);
}
private void AddItem(ReorderableList list)

else
{
list.serializedProperty.InsertArrayElementAtIndex(list.serializedProperty.arraySize);
Vector3 previous = _pathway.transform.position;
Vector3 previous = Vector3.zero;
list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1).FindPropertyRelative("waypoint").vector3Value = new Vector3(previous.x + 2, previous.y, previous.z + 2);
_indexCurrentModification = list.serializedProperty.arraySize - 1;
}

18
UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayGizmos.cs


public class PathwayGizmos
{
[DrawGizmo(GizmoType.Selected)]
private static void DrawGizmosSelected(Pathway pathway, GizmoType gizmoType)
public static void DrawGizmosSelected(PathwayConfigSO pathway, GizmoType gizmoType)
{
if (!pathway.ToggledNavMeshDisplay)
{

}
private static void DrawLabel(Pathway pathway, Vector3 path, int index)
private static void DrawLabel(PathwayConfigSO pathway, Vector3 path, int index)
{
GUIStyle style = new GUIStyle();
Vector3 textHeight = Vector3.up;

Handles.Label(path + textHeight, index.ToString(), style);
}
private static void DrawHandlesPath(Pathway pathway)
private static void DrawHandlesPath(PathwayConfigSO pathway)
{
Handles.color = pathway.LineColor;

}
}
private static void DrawNavMeshPath(Pathway pathway)
private static void DrawNavMeshPath(PathwayConfigSO pathway)
{
Handles.color = pathway.LineColor;

}
}
private static void DrawHitPoints(Pathway pathway)
private static void DrawHitPoints(PathwayConfigSO pathway)
{
if (pathway.DisplayProbes)
{

{
if (pathway.Hits[i])
{
Gizmos.color = new Color(0, 255, 0, 0.5f);
Gizmos.DrawSphere(pathway.Waypoints[i].waypoint, sphereRadius);
Handles.color = new Color(0, 255, 0, 0.1f);
Handles.SphereCap(0, pathway.Waypoints[i].waypoint, Quaternion.identity, sphereRadius);
Gizmos.color = new Color(255, 0, 0, 0.5f);
Gizmos.DrawSphere(pathway.Waypoints[i].waypoint, sphereRadius);
Handles.color = new Color(255, 0, 0, 0.1f);
Handles.SphereCap(0, pathway.Waypoints[i].waypoint, Quaternion.identity, sphereRadius);
}
}
}

4
UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayHandles.cs


public class PathwayHandles
{
private Pathway _pathway;
private PathwayConfigSO _pathway;
public PathwayHandles(Pathway pathway)
public PathwayHandles(PathwayConfigSO pathway)
{
_pathway = pathway;
}

4
UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayNavMesh.cs


public class PathwayNavMesh
{
private Pathway _pathway;
private PathwayConfigSO _pathway;
public PathwayNavMesh(Pathway pathway)
public PathwayNavMesh(PathwayConfigSO pathway)
{
_pathway = pathway;
_pathway.Hits = new List<bool>();

2
UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayHandles.cs.meta


fileFormatVersion: 2
guid: 12817591b14c6404a8be11b932d21ce1
guid: a8dcb713973bd474e9d3eb21e77c8fa4
MonoImporter:
externalObjects: {}
serializedVersion: 2

8
UOP1_Project/Assets/Scripts/Pathway.meta


fileFormatVersion: 2
guid: aaf94d94b26470e4cabe86e27f3fdb27
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

/UOP1_Project/Assets/Scripts/Pathway/Pathway.cs.meta → /UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayHandles.cs.meta

正在加载...
取消
保存